I need to automate the following scenario:
- Open native android app.
- Get user registration code generated to the current user.
- Put the native app in background.
- Open Chrome and navigate to proper back-end URL, enter credentials than register the app (using the user registration code).
- Go back to the native app.....
The problem I have is that I can't to switch the context. I always get only NATIVE_APP context so that I'm not able to switch to WEBVIEW context and use xPath to traverse the DOM elements. getContextHandles() always return only NATIVE_APP context.
I have been looking for solutions about this problem and after a lot of checks I still can't handle it.
Capabilities settings:
cap.setCapability(MobileCapabilityType.PLATFORM_NAME, MobilePlatform.ANDROID);
cap.setCapability(MobileCapabilityType.DEVICE_NAME, DEVICE_NAME);
cap.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());
cap.setCapability(MobileCapabilityType.APP_PACKAGE, APP_PACKAGE);
cap.setCapability(MobileCapabilityType.APP_ACTIVITY, APP_ACTIVITY);
cap.setCapability("device-orientation", "landscape");
cap.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, "100");
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), cap);
Any advice?
Thanks in advance