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(".*历$")')

 

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐