Capability 设置
- app apk 地址
- appPackage 包名
- adb logcat | grep ActivityManager
- adb shell dumpsys activity activities | grep mFocusedActivity
- aapt dumpsys badging com.android.chrome.apk | grep 'launchable-activity'
- automationName 默认使用 uiautomator2(android 默认使用 uiautomator2,ios默认使用 XCUITest)
- noRest fullReset 是否在测试前后重置相关环境(例如首次打开弹窗,或者是登录信息)
- unicodeKeyBoard resetKeyBoard 是否需要输入非英文之外的语言并在测试完成后重置输入法
- 官方文档:https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/caps.md
- dontStopAppOnReset 首次启动的时候,不停止app(可以调试或者运行的时候提升运行速度)
- skipDeviceIntialization 跳过安装、权限设置等操作(可以调试或者运行的时候提升运行速度)
appium 元素定位
- driver.findElementsById(resource-id)
- driver.findElementsbyAccessibilityId(content-desc)
三种经典等待方式
- 强制等待:
- sleep 不推荐
- 隐式等待(全局性)
- 设置一个超时时间,服务端 appium 会在给定的时间内,不停的查找,默认值是0
- 用法:driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
- 在服务端等待
- 显式等待(等待某个元素)
- wait = new WebDriverWait(driver, 10, 1);
- wait.until(ExpectedConditions.visibilityOfElementLocated(MobileBy.id("com.android.settings:id/title")))
- 在客户端等待