Capability 設(shè)置
- 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 默認(rèn)使用 uiautomator2(android 默認(rèn)使用 uiautomator2,ios默認(rèn)使用 XCUITest)
- noRest fullReset 是否在測試前后重置相關(guān)環(huán)境(例如首次打開彈窗,或者是登錄信息)
- unicodeKeyBoard resetKeyBoard 是否需要輸入非英文之外的語言并在測試完成后重置輸入法
- 官方文檔:https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/caps.md
- dontStopAppOnReset 首次啟動(dòng)的時(shí)候,不停止app(可以調(diào)試或者運(yùn)行的時(shí)候提升運(yùn)行速度)
- skipDeviceIntialization 跳過安裝、權(quán)限設(shè)置等操作(可以調(diào)試或者運(yùn)行的時(shí)候提升運(yùn)行速度)
appium 元素定位
- driver.findElementsById(resource-id)
- driver.findElementsbyAccessibilityId(content-desc)
三種經(jīng)典等待方式
- 強(qiáng)制等待:
- sleep 不推薦
- 隱式等待(全局性)
- 設(shè)置一個(gè)超時(shí)時(shí)間,服務(wù)端 appium 會(huì)在給定的時(shí)間內(nèi),不停的查找,默認(rèn)值是0
- 用法:driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
- 在服務(wù)端等待
- 顯式等待(等待某個(gè)元素)
- wait = new WebDriverWait(driver, 10, 1);
- wait.until(ExpectedConditions.visibilityOfElementLocated(MobileBy.id("com.android.settings:id/title")))
- 在客戶端等待