如何从本机应用程序视图切换到网络视图



他们是一个依赖第三方的支付网关,现在在web视图中打开了支付详细信息。因此,如何在原生应用程序中管理web视图并切换上下文。请帮忙!

你可以试试这个。它会起作用的。

driver = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
Set<String> contextNames = driver.getContextHandles();
for (String contextName : contextNames) {
System.out.println(contextName); //prints out something like NATIVE_APP n WEBVIEW_1
}
driver.context(contextNames.toArray()[1]); // set context to WEBVIEW_1
//do some web testing
String myText = driver.findElement(By.cssSelector(".green_button")).click();
driver.context("NATIVE_APP");
// do more native testing if we want
driver.quit();

参考:https://appium.io/docs/en/writing-running-appium/web/hybrid/

最新更新