Summary of the problems caused by the switching of the hybrid app in Appium

Summary of the problems caused by the switching of the hybrid app in Appium


I believe you need to switch between the hybrid apps when using appium, but there will be many inexplicable problems. Here is a summary of my problems.

1
Can not find other contexts . There is a WebView in our Activity, but we can only print a NATIVE_APP when we execute print(driver.contexts). The reason is that your app does not execute the webview debugging function, we need to follow up with development Speaking of setting in webview

webView.setWebContentsDebuggingEnabled(true); 

At this time, if you go to driver.contexts, it will print out other content

2 Unsuccessful switching environment
can find the corresponding context but the switching is unsuccessful

driver.switch_to.context('WEBVIEW_com.example.myapplication')


An error will be reported: An unknown server-side error occurred while processing the command. Original error: No Chromedriver found that can automate Chrome '74.0.3729'. See https://github.com/appium/appium/blob/master/docs/ en/writing-running-appium/web/chromedriver.md for more details. You could also try to enable automated chromedrivers download server feature
. The reason for this problem is that the version of Chromedriver in your appIum and the corresponding webview are not correct. The solution steps are :

 1. 这个时候需要去查看手机webview的版本
方法是:设置-->应用程序管理-->全部-->Android System WebView
 2. 然后去官网下载对应的Chromedriver包  下载地址是:
http://npm.taobao.org/mirrors/chromedriver/
 3. 找对appium安装的路径以我的为参照:
C:\Users\1\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\appium-chromedriver\chromedriver\win
然后替换appium中的驱动包

3 adb的版本过低导致的问题,会报错:
An unknown server-side error occurred while processing the command. Original error: An unknown server-side error occurred while processing the command. Original error: unknown error: Failed to forward ports to device 127.0.0.1:62001. No port chosen: . Perhaps your adb version is out of date. ChromeDriver 2.39 and newer require adb version 1.0.38 or newer. Run ‘adb version’ in your terminal of the host device to find your version of adb.

If this problem occurs, you should download the adb version
Adb in the new anroidsdk. The new version download address is:
adb download address

The final perfect switch!

The above are the problems I have encountered. If you have any other questions, you are welcome to complain! !

Guess you like

Origin blog.csdn.net/yipianfeng_ye/article/details/105564127