getwindowHandle() 抛出方法尚未实现(警告:服务器未提供任何堆栈跟踪信息)错误



在android Web浏览器中实现getwindowhandle时,我收到错误"方法尚未实现(警告:服务器未提供任何堆栈跟踪信息(">

场景是:我需要切换到下一个选项卡并获取 url 并关闭它。

您似乎正在尝试在本机应用程序上下文上执行getWindowHandle()操作,因此应用程序可能会抛出"方法尚未实现(警告:服务器未提供任何堆栈跟踪信息(">

以下是故障排除和解决此问题的方法:

String handle = driver.getWindowHandle();之前添加以下行

//Get all available contexts
Set<String> contexts=driver.getContextHandles();
//Review available contexts on console
System.out.println(contexts);
//Iterate through the contexts
for(String context :contexts){
//Check if the context is webview. If yes, then switch to that context
if(context.toLowerCase().contains("webview")||context.toLowerCase().contains("web_view")){
driver.context(context);
//break the loop if webview context is found and driver switches to webview context
break;
}
}

最新更新