I'm using serenity with appium (v2.3.12)
My scenario require to switch app from native to open chrome and validate a form to create new account then go back in native and try to login.
I use the classic way of serenity.properties to instantiate the appiumDriver and automate the app with UIAutomator2. When I need to switch in chrome I use a new AppiumDriver with the same url and new capabilities like this :
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("automationName", "UIAutomator2");
capabilities.setCapability("browserName", "Chrome");
capabilities.setCapability("UDID", udid);
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("deviceName", "emulator-5554");
capabilities.setCapability("platformVersion", "11.0");
AppiumDriver newDriver = new AndroidDriver(new URL(url), capabilities);
Chrome launch well and I can perform my action.
But the problem is here : when I wan't to switch back.
I tried many ways but none working so far:
First try was to call back my app with :
((AndroidDriver)((WebDriverFacade) getDriver()).getProxiedDriver()).launchApp();
or
((AndroidDriver)((WebDriverFacade) getDriver()).getProxiedDriver()).resetApp();
Native app launch but the driver is not able to find any elements and when I tried to getPageSource :
org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Could not proxy. Proxy error: 'GET /wd/hub/session/f2dd1d65-351f-4845-b321-298e41b7df4d/source' 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
Second try : Do a .quit() the first appiumDriver before using the second but when I do a .launchApp() after chrome actions I got this :
org.openqa.selenium.NoSuchSessionException: Session ID is null. Using WebDriver after calling quit()?
I also try to use two different appium server for each appiumDriver.
Maybe the solution is to relaunch the serenity appiumDriver after quiting and performing action in chrome because I tried to launch a third appiumDriver and it's works well and find elements in native app but it didn't worked with the PageObject from serenity and I don't know how to quit and relaunch the appiumDriver from serenity in a test.
The same process works fine on iOS, when I switch back on app elements are found correctly. Maybe the problem is the way serenity handle UIAutomator2 ?