Android 关于 Appium 自动化的问题
Questions on Appium Automation on Android
问题:
1.App 没有任何 Content-desc,在这种情况下我应该使用什么?调用元素
例如:有一个按钮,当我从 UIautomator 工具检查元素时需要点击该按钮,它在 content-desc 中没有任何内容,我还能考虑什么是识别该元素的最佳方法
例如:资源 ID:au.com.carsguide:id/search_btn
内容描述 - 空白
如果我使用 Resource-id,appium 不会选择那个值,它只能是 "search_btn" 然后它会选择这个值,为什么 resource-id 不支持完整的包名?
- 有什么区别 b/w AndroidDriver 和 RemoteDriver,我应该使用哪一个,如果使用 RemoteDriver 就像我们需要 运行 selenium 服务器吗?
3.I 我能够 运行 实际设备上的 appium 自动化,有人可以帮助我 运行 在 android 模拟器上实现自动化吗?怎么做?
使用 AndroidDriver 时出现以下错误:
FAILED CONFIGURATION: @BeforeClass setUpBeforeClass
java.lang.Error: Unresolved compilation problems:
The return types are incompatible for the inherited methods FindsByAccessibilityId<WebElement>.findElementsByAccessibilityId(String), AppiumDriver<RequiredElementType>.findElementsByAccessibilityId(String)
The return types are incompatible for the inherited methods FindsByCssSelector.findElementsByCssSelector(String), AppiumDriver<RequiredElementType>.findElementsByCssSelector(String)
The return types are incompatible for the inherited methods WebDriver.findElements(By), AppiumDriver<RequiredElementType>.findElements(By)
The return types are incompatible for the inherited methods FindsById.findElementsById(String), AppiumDriver<RequiredElementType>.findElementsById(String)
The return types are incompatible for the inherited methods FindsByLinkText.findElementsByLinkText(String), AppiumDriver<RequiredElementType>.findElementsByLinkText(String)
The return types are incompatible for the inherited methods FindsByXPath.findElementsByXPath(String), AppiumDriver<RequiredElementType>.findElementsByXPath(String)
The return types are incompatible for the inherited methods FindsByName.findElementsByName(String), AppiumDriver<RequiredElementType>.findElementsByName(String)
The return types are incompatible for the inherited methods FindsByTagName.findElementsByTagName(String), AppiumDriver<RequiredElementType>.findElementsByTagName(String)
The return types are incompatible for the inherited methods FindsByLinkText.findElementsByPartialLinkText(String), AppiumDriver<RequiredElementType>.findElementsByPartialLinkText(String)
少即是好。为什么要用包名访问 id ?顺便说一下,您在功能中指定了包名称,因此 appium 在内部使用带有包名称的 id 来定位应用程序组件。如果组件属于其他应用程序,则需要提供 id 及其包名称。
您不需要 运行 selenium 服务器,您需要 运行 Appium 服务器。 AndroidDriver 扩展了 Abstract AppiumDriver,后者又扩展了 DefaultGenericMobileDriver(这也是抽象的),这个抽象 class 又扩展了 RemoteWebDriver。
所以 AndroidDriver 比 RemoteWebDriver 多 APIs/functions。所以你可以选择AndroidDriver。
- 您可以使用Genymotion emulator
- 当模拟器 运行 在终端中执行命令
adb devices
以获取模拟器 ID
- 将模拟器 ID
192.168.56.101:5555
用于 deviceName
和 udid
appium capabilities
问题:
1.App 没有任何 Content-desc,在这种情况下我应该使用什么?调用元素 例如:有一个按钮,当我从 UIautomator 工具检查元素时需要点击该按钮,它在 content-desc 中没有任何内容,我还能考虑什么是识别该元素的最佳方法
例如:资源 ID:au.com.carsguide:id/search_btn 内容描述 - 空白
如果我使用 Resource-id,appium 不会选择那个值,它只能是 "search_btn" 然后它会选择这个值,为什么 resource-id 不支持完整的包名?
- 有什么区别 b/w AndroidDriver 和 RemoteDriver,我应该使用哪一个,如果使用 RemoteDriver 就像我们需要 运行 selenium 服务器吗?
3.I 我能够 运行 实际设备上的 appium 自动化,有人可以帮助我 运行 在 android 模拟器上实现自动化吗?怎么做?
使用 AndroidDriver 时出现以下错误:
FAILED CONFIGURATION: @BeforeClass setUpBeforeClass
java.lang.Error: Unresolved compilation problems:
The return types are incompatible for the inherited methods FindsByAccessibilityId<WebElement>.findElementsByAccessibilityId(String), AppiumDriver<RequiredElementType>.findElementsByAccessibilityId(String)
The return types are incompatible for the inherited methods FindsByCssSelector.findElementsByCssSelector(String), AppiumDriver<RequiredElementType>.findElementsByCssSelector(String)
The return types are incompatible for the inherited methods WebDriver.findElements(By), AppiumDriver<RequiredElementType>.findElements(By)
The return types are incompatible for the inherited methods FindsById.findElementsById(String), AppiumDriver<RequiredElementType>.findElementsById(String)
The return types are incompatible for the inherited methods FindsByLinkText.findElementsByLinkText(String), AppiumDriver<RequiredElementType>.findElementsByLinkText(String)
The return types are incompatible for the inherited methods FindsByXPath.findElementsByXPath(String), AppiumDriver<RequiredElementType>.findElementsByXPath(String)
The return types are incompatible for the inherited methods FindsByName.findElementsByName(String), AppiumDriver<RequiredElementType>.findElementsByName(String)
The return types are incompatible for the inherited methods FindsByTagName.findElementsByTagName(String), AppiumDriver<RequiredElementType>.findElementsByTagName(String)
The return types are incompatible for the inherited methods FindsByLinkText.findElementsByPartialLinkText(String), AppiumDriver<RequiredElementType>.findElementsByPartialLinkText(String)
少即是好。为什么要用包名访问 id ?顺便说一下,您在功能中指定了包名称,因此 appium 在内部使用带有包名称的 id 来定位应用程序组件。如果组件属于其他应用程序,则需要提供 id 及其包名称。
您不需要 运行 selenium 服务器,您需要 运行 Appium 服务器。 AndroidDriver 扩展了 Abstract AppiumDriver,后者又扩展了 DefaultGenericMobileDriver(这也是抽象的),这个抽象 class 又扩展了 RemoteWebDriver。
所以 AndroidDriver 比 RemoteWebDriver 多 APIs/functions。所以你可以选择AndroidDriver。
- 您可以使用Genymotion emulator
- 当模拟器 运行 在终端中执行命令
adb devices
以获取模拟器 ID - 将模拟器 ID
192.168.56.101:5555
用于deviceName
和udid
appium capabilities