I’m using a cloud service (Kobiton) to run our local devices. These are the capabilties I’m using for the device:
sessionName=Automation test session
noReset=true
fullReset=false
deviceOrientation=portrait
captureScreenshots=true
groupId=590
deviceGroup=ORGANIZATION
browserName=Safari
automationName=XCUITest
ios_app=kobiton-store:34092
nativeInstrumentsLib=true
When I run this through Appium Inspector, I’m able to locate elements that are in webview. For my code, I initialize the driver as AppiumDriver< MobileElement >. When I reach the screen that is webview I have my code change the context to Webview with this code:
Set<String> contextNames = driver.getContextHandles();
for (String name : contextNames) {
System.out.println("context: "+ name);
}
driver.context((String) contextNames.toArray()[1]);
And I’ve checked it does set the context to Webview. Then when calling the page object I’ve tried passing the driver as is, and finding elements with @iOSXCUITFindBy annotation, and setting it as MobileElement. I’ve also tried setting as WebElement. I did also try finding the element these ways:
MobileElement loginBTN = driver.findElementByAccessibilityId("Log in");
or:
WebElement loginBTN = driver.findElementByAccessibilityId("Log in");
All of this returned NoSuchElementException
I also read on here to cast WebDriver TO the mobile driver, and I’ve tried this when passing to the page object along with setting content to webview:
fb = new FacebookLogin((WebDriver) driver, action);
or:
fb = new FacebookLogin((RemoteWebDriver) driver, action);
When I tried this way, I would make sure to set the page to using this driver, but when I did this I would get an error saying NullPointer - which I think means it’s making the driver null? I don’t understand why this is.
I read somewhere that you need to set web-driver-debug-proxy and set the capability for it to true, but even though this is a physical device, it’s being ran through Kobiton cloud service so i cannot run the debug-proxy… If someone could help me resolve this issue I would greatly appreciate it as we need to be able to test logging in through facebook! If you need more information I will be happy to grab it.