Appium测试中,getElementByLinkText(), getElementByAccessibility需要切换到webview,直接使用driver.switchToWebview()不能解决问题,可尝试以下解决方案:
Set<String> contextNames = driver.getContextHandles();
for (String contextName : contextNames) {
if (contextName.contains("WEBVIEW")){
driver.context(contextName);
return;
} else
{
System.out.println("no WEBVIEW");
}
}
}
奇怪的是,webview切换到了带":vpushservice"的那个能work,不大清楚为什么。