1.weditor環(huán)境準(zhǔn)備:
使用pip安裝weditor,github地址https://github.com/openatx/weditor
- python環(huán)境:2.7
- 安裝:
pip install weditor
- 安裝:
pip install uiautomator2
2.運行:
python -m weditor
python -m uiautomator2 init
看到窗口出現(xiàn)如下信息,就是啟動成功了(窗口別關(guān)掉了)
C:\Users\dell>python -m weditor
listening on http://192.168.1.125:17310
[I 190717 23:50:55 web:2246] 304 GET / (::1) 7.98ms
[I 190717 23:50:55 web:2246] 304 GET /static/libs/css/buttons.css (::1) 196.47ms
[I 190717 23:50:55 web:2246] 304 GET /static/loading.svg (::1) 5.99ms
[I 190717 23:50:55 web:2246] 304 GET /static/ace/ace.js (::1) 12.97ms
[I 190717 23:50:55 web:2246] 304 GET /static/running.svg (::1) 13.96ms
[I 190717 23:50:55 web:2246] 304 GET /static/ace/mode-python.js (::1) 19.96ms
[I 190717 23:50:55 web:2246] 304 GET /static/libs/fontawesome/css/font-awesome.min.css (::1) 1.99ms
[I 190717 23:50:59 web:2246] 304 GET /api/v1/version (::1) 0.00ms
3.weditor連接手機
先使用adb連上手機艺演,輸入adb devices查看手機設(shè)備號:
C:\Users\dell>adb devices
List of devices attached
adb server version (31) doesn't match this client (40); killing...
* daemon started successfully
emulator-5554 device
在頁面上輸入手機設(shè)備號娇澎,點Connet按鈕焕窝,看到出現(xiàn)一個小草的圖標(biāo)音瓷,就是連接成功了
image.png
4.頁面元素抓取
定位元素
定位元素的方法支持uiautomator
的定位方法锦庸,也可以支持xpath和坐標(biāo)定位
- 1.可以查看元素的
resourceId
屬性 - 2.自動生成
xpath
定位方法 - 3.支持坐標(biāo)點擊敬锐,根據(jù)屏幕的比例
- 4.自動生成
uiautomator
定位方法參考代碼 - 5.可以勾選強制使用
xpath
image.png
操作步驟:點勾選高鐵動車后,點查詢按鈕
Ctr+Enter
運行代碼剩盒,會發(fā)現(xiàn)手機上已經(jīng)點擊成功
5.在線Coding調(diào)試
可以在頁面的右邊調(diào)試運行代碼谷婆,這點比appium強很多,可以編寫代碼邊調(diào)試辽聊,還是非常方便的
6.支持wifi連接
首先保證電腦和手機wifi在一個局域網(wǎng)纪挎,電腦上能ping的通手機的ip,輸入手機的ip也可以抓到手機上的頁面元素跟匆。