mac搭建appium环境之设置chromdriver
背景:
appium對app進行UI自動化測試,原生頁面切換到webview頁面時,driver也要從NATIVE_APP切換到WEBVIEW_xxxxx,這個切換過程經常會出現chromdriver與安卓設備的webview版本不一致造成切換失敗,從而不能執行后續對web頁面元素操作的情況。
解決方案:
1、手動下載與安卓設備自帶的webview相匹配的版本的chromedriver(注意與安卓設備的chrome瀏覽器和PC端chrome瀏覽器的版本沒有任何關系);chromedriver下載地址為https://chromedriver.storage.googleapis.com/index.html 該地址可以分別看到不同版本的chromedriver支持的安卓設備的webview版本的范圍值,安卓設備上的webview版本號可以從設備上或appium的日志中找到,不再贅述。
- 1)將下載好的chromedriver放到mac中指定的路徑下(覆蓋掉之前的),路徑如下,也可自定義
- 2)在appium初始化代碼中加入Capability參數,服務運行時會自動找該路徑下的chromedriver
2、程序自動下載與當前測試設備webview版本一致的chromedriver,從Appium 1.15.0及以上版本支持;避免了主動尋找chromedriver的繁瑣,官網說明文檔:
https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/web/chromedriver.md#automatic-discovery-of-compatible-chromedriver
截取如下:
-Since Appium 1.15.0 there is a possibility to automatically download the necessary chromedriver(s) into chromedriverExecutableDir from the
official Google storage. The script will automatically search for the
newest chromedriver version that supports the given browser/web view,
download it (the hash sum is verified as well for the downloaded
archive) and add to the chromedriverChromeMappingFile mapping.
Everything, which is needed to be done from your side is to execute
the server with chromedriver_autodownload feature enabled (like appium
–allow-insecure chromedriver_autodownload). You can also check the Security document for more details on how to control potentially
insecure server features.
翻譯一下:
appium從1.15.0開始,具備了自動下載必需的chromedriver到chromedriverExecutableDir下的功能,程序會自動尋找符合當前設備webview版本的最新的chromedriver版本并自動下載然后加入到chromedriverChromeMappingFile映射文件中,你需要做的唯一的事情就是在服務端執行具有自動下載特征的命令,如:appium --allow-insecure chromedriver_autodownload
- 1)初始化代碼中加入下面幾行
自動下載的chromedriver會放置到…/mac/路徑下;
自動下載的chromedriver會在chromedriver_support.json文件中形成相應的版本記錄,該文件是json格式,可以自建空白文件打開后用{}括上即可。
- 2)在appium服務端執行 appium --allow-insecure chromedriver_autodownload 該命令即可使自動下載chromedriver生效。
附1:http://appium.io/docs/en/writing-running-appium/caps/ (Capability參數詳解)
原博文地址:http://54gwz.cn/article/1594204169
總結
以上是生活随笔為你收集整理的mac搭建appium环境之设置chromdriver的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: springboot使用定时器及发送邮件
- 下一篇: appium适用场景