I am testing the Facebook application where at one point of time it launches the Instant Articles which is a webview? Appium is unable to identify objects in web-view. I can’t switch to web view for it to identify the elements, i have tried many possible ways but nothing seems to be working. Any help here is really appreciated.
// Example: Native or Webview
Set<String> contexts = driver.getContextHandles();
// made sure we have web view content
// assertThat(contexts.size(), greaterThan(1));
for (String context : contexts) {
System.out.println(contexts);
if (!context.equals("NATIVE_APP")) {
driver.context((String) contexts.toArray()[1]);
break;
}
}
System.out.println("execute context switch successfully!!! "
+ contexts.toArray()[1]);
driver.findElementByClassName("example.example").click();
I recommend searching on this site for this topic as it comes up frequently and there is a great amount of information already available. The most common answer is
Does your app set setWebContentsDebuggingEnabled to true?
Without that, it doesn’t matter what you do on the testing side.
@willosser could you please tell me how I can set “setWebContentsDebuggingEnabled” to True? I’m trying to switch from native to web but nothing happens…so maybe that is the problem? Do I need to set that somewhere or ask my iOS dev to do that?
FYI…I do see the website context name printed in my console as part of System.out.println("…contextName: " + contextName);
So maybe the issue is something else?
I have a problem in switching my Hybrid application from Native APP context view to Web Context view with new Appium 1.6.4 version.
can you please let me know if anyone encountered this ?
Sample Code Used:
Set contextName = driver.getContextHandles();
System.out.println(contextName);
for (String contexts : contextName) {
System.out.println(contexts);
if (contextName.contains(“NATIVE_APP”)) {
System.out.println(“Show me:” + contextName);
Thread.sleep(1500);
driver.context(“NATIVE_APP”);
driver.findElement(By.xpath("//android.widget.Button[@text=‘Set’]")).click();
}
if (contextName.contains(“WEBVIEW”)) {
driver.context(“WEBVIEW”);
driver.findElement(By.xpath("//android.widget.Button[@text=‘Set’]")).click();
}
Have you managed to switch the context to webview? I am trying do write test cases in javascript for frontend of my iOS app and using iOS simulator and using safari develop-> simulator to see on webview.
p.s; i have tried changing the desired capabilities setWebContentsDebuggingEnabled: true but it’s not making any difference
To switch context, used: autoWebview: true, in desiredCapabilities opts
While trying to switch i am facing below error,
Error: Could not start ios_webkit_debug_proxy server: Timed out waiting for ios_webkit_debug_proxy to open
Below is the detailed Logs of the issue, Let me know how to resolve this.
Thanks in advance.
[debug] [BaseDriver] Event ‘iwdpStarting’ logged at 1524116635774 (11:13:55 GMT+0530 (IST))
[debug] [iOS] Starting ios_webkit_debug_proxy at port 27753 on device c4d6484b3080efbed6ce588597ebf3e47cd6154e[debug] [iOS] Starting ios_webkit_debug_proxy at port 27753 on device c4d6484b3080efbed6ce588597ebf3e47cd6154e[debug] [iOS] Starting ios_webkit_debug_proxy at port 27753 on device c4d6484b3080efbed6ce588597ebf3e47cd6154e
[error] [iOS] Error: Timed out waiting for ios_webkit_debug_proxy to open
at Object.wrappedLogger.errorAndThrow (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-support/lib/logging.js:69:13)
at IWDP.start$ (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-ios-driver/lib/iwdp.js:61:14)
at tryCatch (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
at GeneratorFunctionPrototype.invoke (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
at
Error: Timed out waiting for ios_webkit_debug_proxy to open
at Object.wrappedLogger.errorAndThrow (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-support/lib/logging.js:69:13)
at IWDP.start$ (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-ios-driver/lib/iwdp.js:61:14)
at tryCatch (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
at GeneratorFunctionPrototype.invoke (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
at
[error] [XCUITest] Error: Could not start ios_webkit_debug_proxy server: Timed out waiting for ios_webkit_debug_proxy to open