driver.getPageSource() 查看 resource-id 元素存在,如截图:
确定元素存在后 获取该元素:
WebElement foundElement = driver.findElement(By.id("com.youku.phone:id/definition_btn"));
最后报错:
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'youkudeMacBook-Pro.local', ip: 'fe80:0:0:0:f8:5221:13f0:e6b1%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.4', java.version: '1.8.0_112-release'
Driver info: io.appium.java_client.android.AndroidDriver
Capabilities [{appPackage=com.youku.phone, deviceScreenSize=1080x1920, networkConnectionEnabled=true, warnings={}, databaseEnabled=false, deviceName=2f71e0b5, platform=LINUX, deviceUDID=2f71e0b5, appActivity=com.youku.ui.activity.HomePageActivity, desired={appPackage=com.youku.phone, appActivity=com.youku.ui.activity.HomePageActivity, newCommandTimeout=240.0, platformVersion=6.0.1, automationName=Appium, javascriptEnabled=true, unicodeKeyboard=true, platformName=Android, udid=2f71e0b5, deviceName=2f71e0b5}, newCommandTimeout=240.0, platformVersion=6.0.1, webStorageEnabled=false, locationContextEnabled=false, automationName=Appium, takesScreenshot=true, javascriptEnabled=true, deviceModel=vivo X9i, unicodeKeyboard=true, platformName=Android, udid=2f71e0b5, deviceManufacturer=vivo}]
Session ID: f2177662-fcfa-4d95-a007-b69980768842
*** Element info: {Using=id, value=com.youku.phone:id/definition_btn}