如何从本机应用程序视图切换到Webview?

问题描述

他们是一个依赖第三方的支付网关,现在在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/

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...