android
android uiautomator在sdk/tools/bin文件夾下,有一個uiautomatorviewer.bat
點擊即可啓動
需要注意的是adb連接問題,可以嘗試下面命令
adb kill-server
在cmd中輸入命令:netstat -ano|findstr "5037"
,查看5037端口占用情況,
tasklist|findstr xxxx
輸入adb devices
,如果有設備名稱說明連接沒有問題
python
uiautomator安裝
pip install uiautomator
uiautomator項目地址:github
使用示例:
def test_open_app(self):
app_text = "BobbyApp"
try:
# 按下home按鍵
d.press.home()
time.sleep(1)
# 按下應用按鈕
d.click(400, 1100)
time.sleep(1)
# 按下需要測試的應用
self.assertEqual(check_controls_exists(app_text), True, msg=app_text + " 按鈕不存在")
d(text=app_text).click()
print("--------------test_open_app OK")
except Exception as e:
print("Error: 沒有打開app\n", e)
演示效果:
項目地址:碼雲