小菜鸡Appium掉坑之Native切换WebView

参考:

https://www.cnblogs.com/sao-fox/p/6396984.html

问题描述:driver.context("WEBVIEW")报错,java.lang.NoSuchMethodError啥的各种报错,结果就是最后打不开。

Code:
Set contextNames = driver.getContextHandles();
for (String contextName : contextNames) {
System.out.println(contextNames); //输出 NATIVE_APP \n WEBVIEW_1
}
driver.context("WEBVIEW");

Error:

info: JSONWP Proxy: Got response with status 200: {"sessionId":"111111","status":33,"value":{"message":"session not created exception\nfrom unknown error: Runtime.executionContextCreated has invalid 'context': {"auxData...
error: Chromedriver: Chromedriver exited unexpectedly with code null, signal SIGTERM
info: Chromedriver: Changed state to 'stopped'
warn: Chromedriver for context WEBVIEW_com.xxx.xxx stopped unexpectedly
warn: Chromedriver quit unexpectedly, but it wasn't the active context, ignoring
error: Chromedriver: Error: A new session could not be created. (Original error: session not created exception
from unknown error: Runtime.executionContextCreated has invalid 'context': {"auxData":{"frameId":"17609.1","isDefault":true},"id":1,"name":"","origin":"://"}
(Session info: chrome=55.0.2883.91)
(Driver info: chromedriver=2.18.343845 (73dd713ba7fbfb73cbb514e62641d8c96a94682a),platform=Windows NT 6.1 SP1 x86_64))

处理办法:
更换appium的chromedriver.exe的版本就行。

首先,Android app 的webview 使用的 Chrome的内核,这时候检查一下 Android System WebView的版本,我的是华为的,设置 - 应用管理 在app list 里面下面,找到Android System WebView:

image.png

Android System WebView 版本是 55.02883.91

然后有一张很神奇的 Chrome 和 Chromedriver 的版本对照表:

image.png

然后55对应的是:


image.png

这个时候要去找自己appnium的Chromedriver是什么版本:
C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-chromedriver\chromedriver\win
我的地址。点击


image.png
image.png

呵呵哒
Chromedriver直通车:
http://chromedriver.storage.googleapis.com/index.html
我的55 对应2.27

image.png

替换掉
C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-chromedriver\chromedriver\win
image.png

然后就好了~

你可能感兴趣的:(小菜鸡Appium掉坑之Native切换WebView)