appium 学习记录
环境搭建
java 和 Android-SDK
sdkmanager 安装 SDK-Tools platform-tools build-tools
最少安装一个版本的 sdk-platform
Node.js安装
Appium-desktop
Appium-client(pip安装 或者 github上下载安装)
uiautomatorviewer 自己截图 定位
adb shell uiautomator dump /sdcard/app.uix adb pull /sdcard/app.uix F:/app.uix adb shell screencap -p /sdcard/app.png adb pull /sdcard/app.png F:/app.png
获取packageName 和 入口activity aapt dump badging //path cmd需要cd 到path 去, 不然 可能会“dump failed because no AndroidManifest.xml found” 或者 打印手机日志 adb logcat -v time -s ActivityManager | findstr name=
定位
driver.find_element_by_id('com.tencent.mobileqq:id/btn_login')
driver.find_element_by_xpath('//android.widget.EditText[@content-desc="请输入QQ号码或手机或邮箱"]')
driver.find_element_by_accessibility_id('请输入QQ号码或手机或邮箱') content-desc
AndroidUiautomator定位
# 包含text文字
driver.find_element_by_android_uiautomator('new UiSelector().textContains("机")')
# 以text什么开始
driver.find_element_by_android_uiautomator('new UiSelector().textStartsWith("手")')
# 正则匹配text
driver.find_element_by_android_uiautomator('new UiSelector().textMatches("^手.*")')
# className
driver.find_elements_by_android_uiautomator('new UiSelector().className("android.widget.TextView")')
# classNameMatches
driver.find_elements_by_android_uiautomator('new UiSelector().classNameMatches("^android.widget.*")')
# resource-id、resourceIdMatches
driver.find_element_by_android_uiautomator('new UiSelector().resourceId("com.syqy.wecash:id/et_content")')
# description
driver.find_element_by_android_uiautomator('new UiSelector().description("S 日历")')
# descriptionStartsWith
driver.find_element_by_android_uiautomator('new UiSelector().descriptionStartsWith("日历")')
# descriptionMatches
driver.find_element_by_android_uiautomator('new UiSelector().descriptionMatches(".*历$")')
竹杖芒鞋轻胜马,一蓑烟雨任平生。
回首向来萧瑟处,也无风雨也无晴。
浙公网安备 33010602011771号