0

为了自动化 android 应用程序,我正在使用 AppiumDriver

 AppiumDriver driver = new AppiumDriver(new URL("http://localhost:5555/wd/hub"), capabilities);

我在网络上使用 RemoteWebDriver 找到了

 RemoteWebDriver driver = new RemoteWebDriver(new URL("http://localhost:5555/wd/hub"), capabilities);

是否需要使用不同的驱动程序。如果是,对于自动化 iOS 应用程序,我需要使用哪个驱动程序?

4

1 回答 1

1

使用什么驱动程序有多种可能性,不同之处在于您希望有多少平台特定功能可用。

对于 Android,最具体的驱动程序是 AndroidDriver。AndroidDriver 扩展了 AppiumDriver(您现在正在使用的那个),而 AppiumDriver 扩展了 RemoteWebDriver。换句话说,RemoteWebDriver 的功能最少,而使用驱动程序更进一步会带来更多选择。

Java客户端的AndroidDriver: http ://appium.github.io/java-client/io/appium/java_client/android/AndroidDriver.html

在 API 文档页面中可以看到 AndroidDriver 的继承:

java.lang.Object
  org.openqa.selenium.remote.RemoteWebDriver
    io.appium.java_client.AppiumDriver<T>
      io.appium.java_client.android.AndroidDriver<T>

请注意,AppiumDriver 和 AndroidDriver 包含 <T>,它允许您选择正在使用的 MobileElements 类型。要访问驱动程序的所有 Android 特定功能,您可能需要将 <T> 定义为 <AndroidElement>:http ://appium.github.io/java-client/io/appium/java_client/android/AndroidElement.html

AndroidElement的继承:

java.lang.Object
  org.openqa.selenium.remote.RemoteWebElement
    io.appium.java_client.MobileElement
      io.appium.java_client.android.AndroidElement

iOS 也有类似的 IOSDriver:http ://appium.github.io/java-client/io/appium/java_client/ios/IOSDriver.html 继承:

java.lang.Object
  org.openqa.selenium.remote.RemoteWebDriver
    io.appium.java_client.AppiumDriver<T>
      io.appium.java_client.ios.IOSDriver<T>

在许多情况下,只需将 AppiumDriver 与 <WebElement> (默认使用)或 <MobileElement> 一起使用就足够了

于 2016-08-25T10:42:10.020 回答