关于移动应用程序自动化中的驱动程序

Regarding drivers in mobile app automation

为了自动化 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);

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

使用 driver 有多种可能性,不同之处在于您希望有多少平台特定功能可用。

对于 Android,最具体的 driver 将是 AndroidDriver。 AndroidDriver 扩展了 AppiumDriver(您现在正在使用的那个)并且 AppiumDriver 扩展了 RemoteWebDriver。换句话说,RemoteWebDriver 的功能最少,再往上一层 driver 会带来更多选择。

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

AndroidDriver 的继承,如 API 文档页面所示:

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

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

Android元素的继承:

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 与 (默认使用)或

一起使用就足够了