參考文檔:http://www.automationtestinghub.com/download-and-install-appium-1-6/
一、首先明白appium1.5以后的版本才支持toast定位,所以下載最新的appium
下載地址:https://github.com/appium/appium-desktop/releases
(mac下載的dmg結尾的包,windows下載exe結尾的包)
下載完成后,安裝安裝包即可:
如下表示啟動成功:
二、抓到toast需要安裝uiautomator2,npm安裝不了時,可以先安裝NPM鏡像,地址:https://npm.taobao.org/ ;
1. 首先執行這個命令:npm install -g cnpm --registry=https://registry.npm.taobao.org
安裝cnpm(完成后如下圖):
2. 然后通過這個命令: cnpm install appium-uiautomator2-driver 安裝uiautomator2的配置文件,如圖:
mac本需要自主下載兩個apk,(appium-uiautomator2-server-v0.1.8.apk 、appium-uiautomator2-server-debug-androidTest.apk)
需要放在本機 path /usr/local/lib/node_modules/appium/node_modules/appium-uiautomator2-driver/uiautomator2/ 目錄下面
下載地址:https://github.com/appium/appium-uiautomator2-server/releases
3. 需要導入的包:
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
4. 代碼中的配置如下:
5. 獲取toast的定位代碼如下:
6. 大功告成:
參考的網站:
http://www.cnblogs.com/meitian/p/7360017.html
https://npm.taobao.org/
https://testerhome.com/topics/6685#weixin.qq.com
https://github.com/appium/appium-uiautomator2-server/releases
http://blog.csdn.net/songer_xing/article/details/71272566