I am automating an app inside a container app on a physical iOS device. Both container and child applications are hybrid. I cannot get the appium server to click on an element in the child application. I tried switching window handles but that didn’t help. Any thoughts?
String context=wd.getContext();
System.out.print(context);
for (String winHandle : wd.getWindowHandles()) {
System.out.println("Handle is " + winHandle);
try{
wd.findElementByXPath("//*[@id='xyz']").click();
//TouchActions touchAction = new TouchActions(wd);
//touchAction.singleTap(sft).build().perform();
}
catch(NoSuchElementException e){
System.out.println(e.getMessage());
continue;
}
wd.switchTo().window(winHandle); // switch focus of WebDriver to the next found window handle (that's your newly opened window)
checkPageIsReady(wd);
}
}
}
Here’s a sample console output for an iteration:
WEBVIEW_14Handle is 14
An element could not be located on the page using the given search parameters. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 10.59 seconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: ‘2.53.0’, revision: ‘35ae25b1534ae328c771e0856c93e187490ca824’, time: ‘2016-03-15 10:43:46’
System info: host: ‘m-C02S403ZG8WL.local’, ip: ‘10.4.88.155’, os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.11.5’, java.version: ‘1.7.0_80’
*** Element info: {Using=xpath, value=//asterisk[@id=‘xyz’]}
Session ID: 9f40fd70-edc4-4ee0-9cad-3f7c7b0b8986
Driver info: io.appium.java_client.ios.IOSDriver
Capabilities [{automationName=Appium, platform=MAC, app=something, javascriptEnabled=true, browserName=, networkConnectionEnabled=true , sendKeyStrategy=grouped, desired={automationName=Appium, app=something, platformVersion=9.2, autoWebview=true, deviceName=iPhone 6s, platformName=iOS, appium-version=1.0, networkConnectionEnabled=true , sendKeyStrategy=grouped, udid=d4b1154e8ec570c69c971be7462acb66ea351b9b}, udid=d4b1154e8ec570c69c971be7462acb66ea351b9b, locationContextEnabled=false, platformVersion=9.2, autoWebview=true, databaseEnabled=false, deviceName=iPhone 6s, platformName=iOS, appium-version=1.0, webStorageEnabled=false, takesScreenshot=true}]