Open yagyeshsahu-cred opened 1 year ago
So, the issue was that you started UIAutomator2
and then flutter
automation name without deleting the session, correct?
It looks like the behavior was expected since the first uia2 session was not correctly stopped. The flutter driver uses UIA2 driver to manage the device/android app as the readme. The 2nd flutter driver session did not start the uia2 session used in the flutter driver properly.
Maybe you need to launch the flutter automation name without app
nor appPackage
, then need to start the app from mobile:startAppActivity
etc in the NATIVE_APP context. Then need to attach to the observatory url in the expected timing with flutter:connectObservatoryWsUrl
. https://github.com/appium/appium-flutter-driver?tab=readme-ov-file#several-ways-to-start-an-application has some ideas to establish the flutter
Correct. Started UIAutomator2 and then flutter automation name without deleting the session.
Requirement is to switch between native and flutter contexts while navigating from native to flutter screen and back to native in the same session, without relaunching app. We will lose the screen we want to perform further actions.
Ours is a hybrid app with first activity load on native screen. So, we cannot start app with appium flutter driver because attaching observatory url fails.
Execution starts with native android driver with automation name uia2. switched Context to flutter and performed actions. Further switching context to native fails..
Started UIAutomator2 -> perform actions in native screen -> initialised flutter driver with automation name "Flutter" without deleting the session. -> switch context to native fails with below error
[HTTP] <-- POST /wd/hub/session/0a5f1f51-28d6-4fe5-9bde-424193df016a/appium/device/activate_app 200 548 ms - 14 [HTTP] [HTTP] --> GET /wd/hub/session/0a5f1f51-28d6-4fe5-9bde-424193df016a [HTTP] {} [debug] [AndroidUiautomator2Driver@5cb2 (0a5f1f51)] Calling AppiumDriver.getSession() with args: ["0a5f1f51-28d6-4fe5-9bde-424193df016a"] [debug] [AndroidUiautomator2Driver@5cb2 (0a5f1f51)] Getting session details from server to mix in [debug] [AndroidUiautomator2Driver@5cb2 (0a5f1f51)] Encountered internal error running command: UnknownError: An unknown server-side error occurred while processing the command. Original error: 'GET /' cannot be proxied to UiAutomator2 server because the instrumentation process is not running (probably crashed). Check the server log and/or the logcat output for more details [debug] [AndroidUiautomator2Driver@5cb2 (0a5f1f51)] at UIA2Proxy.command (/opt/homebrew/lib/node_modules/appium/node_modules/@appium/base-driver/lib/jsonwp-proxy/proxy.js:355:13) [debug] [AndroidUiautomator2Driver@5cb2 (0a5f1f51)] at processTicksAndRejections (node:internal/process/task_queues:95:5) [debug] [AndroidUiautomator2Driver@5cb2 (0a5f1f51)] at AndroidUiautomator2Driver.getSession (/opt/homebrew/bin/node_modules/appium-uiautomator2-driver/lib/driver.js:269:20)
Scenario - switch between 3 pages to automate feature without relaunching app in between. Page 1 - native Page 2 - Flutter Page 3 - Native
Did you try out below suggestion way in my previous comment?
Maybe you need to launch the flutter automation name without app nor appPackage, then need to start the app from mobile:startAppActivity etc in the NATIVE_APP context. Then need to attach to the observatory url in the expected timing with flutter:connectObservatoryWsUrl. https://github.com/appium/appium-flutter-driver?tab=readme-ov-file#several-ways-to-start-an-application has some ideas to establish the flutter
So, the flow would be:
automationName: flutter
without app nor appPackageflutter:connectObservatoryWsUrl
Thank you. Yes, With app already installed, these steps worked.
Is there a way where we do not have to launch the app using startActivityApp at test case level. Is there a way to launch/install app using capabilities with above mentioned steps. Currently initialising driver at base test level and passing driver to test class.
Also, we also have web views in app. is there a way to use 2 drivers automation name uiA2 & flutter performing actions on same client without changing app state during context switching. May be in thread safe manner.
launch/install app using capabilities with above mentioned steps
In which set[? For now, my last comment had two launching app cases as below
A. launching an app without checking the observatory URL, B. launching an app with checking the observatory URL and attaching to it
As Appium's design, it expects to be used with 1) launching one app in a new session creation, or 2) starting a session without launching any apps and launching multiple apps etc as test setup before proceeding test steps like my previous comment. So putting the above A and B into one new session request is not for the design's usage.
You may be able to build appium's plugin by yourself to handle such a thing I guess. https://appium.io/docs/en/2.0/ecosystem/build-plugins/
use 2 drivers automation name uiA2 & flutter performing actions on same client without changing app state during context switching
Not possible with vanilla drivers since the flutter driver also uses uia2 driver internally to handle the app. A device can have one app process that has the same package name. So if you prepare customized uia2 driver by yourself, potentially it would be possible, but it requires your own customization in the driver (appium uiautomator2 server) level
How can we handle multiple context switching from native to flutter to native using Appium?
Switching context from native to flutter works seamlessly with appium flutter driver. Switching context back from flutter to native throws below error. We cannot use flutter driver as the app is hybrid and uses only few flutter and web views.
Steps - perform actions on native screen. -> Flutter screen loads -> switch to flutter context using driver.context("Flutter"); -> perform actions on flutter screen --> navigate to native screen --> switch to native view throws error
reference issue - https://github.com/appium/appium/discussions/19115