appium-espresso-driver
appium-espresso-driver copied to clipboard
jetpack compose support
<< ref: https://github.com/appium/appium/issues/15138 >>
We are migrating our app to compose and plan to add composeTestRule support inside appium-espresso-driver. Before moving forward with any change, I wanted to check upon the approach so that it could be integrated into existing code seamlessly. We plan to introduce a switch between espresso and composeTestRule. we could utilize switch_context or execute_script to switch between contexts. on the espresso-server side, based on the current context of the driver, we can use either implementation. Please suggest if you have any other ideas
context switch seems promising for such purpose, although I'm not sure it would be easy to update its current implementation without breaking many things as it was only created to switch to Chrome web views. What might be simpler is to organize context switch using settings API
Haven't seen espresso using settings API, any pointer to it will be helpful. we could also do something like execute_script("mobile: switch_to_compose") or execute_script("mobile: switch_to_espresso") ?
yes. Something like mobile: setServerContext
(name: classic
or compose
) and mobile: getServerContext
Examples: https://github.com/appium/appium-mac2-driver/pull/28 https://github.com/appium/appium-mac2-driver/pull/30
it would still be worth exploring the strategy of using the official context API. if that works sensibly, it will be a much better user experience.
I remember I was trying to make the context stuff working with Firefox. My findings were:
- Most of the code lives in appium-android-driver. Changing that will affect all Android drivers
- The current implementation is very Chrome-specific. It was not developed for further extension
- Some parts of the codebase are quite cryptic. It might take a lot of time to understand them not even talking about how to change them without breaking the existing functionality
You're probably right. I was thinking of something simple like a wrapper around the existing functionality that simply adds a new context to the list and handles the case of selecting that context. Otherwise, everything is handled by just calling the existing methods.
Its promising! Initially I thought a bit:
- define a context like WebView/Native to be able to switch to
compose
- define a new look up like
-android viewmatcher
to manage an element object- add
mobile:
for new actions if needed
- add
- add
mobile: getComposSource
https://developer.android.com/jetpack/compose/testing#debugging as a workaround- until we add xml converter
I don't remember well, but when I dig in some compose code/appium espresso before, this espresso driver probably needed to up to dated (e.g. kotlin version(?)).
Kotlin version was updated in https://github.com/appium/appium-espresso-driver/pull/663 and it worked for me with composeTestRule. My thought was to have context object having strategies for espressoAutomation and composeAutomation