【问题标题】:Regarding drivers in mobile app automation关于移动应用自动化中的驱动程序
【发布时间】:2016-08-25 18:42:10
【问题描述】:

为了自动化 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 应用程序,我需要使用哪个驱动程序?

【问题讨论】:

    标签: appium appium-ios android-auto


    【解决方案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 包含 ,它允许您选择正在使用的 MobileElement 类型。要访问驱动程序的所有 Android 特定功能,您可能需要将 定义为 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 与 (默认使用)或 一起使用就足够了

    【讨论】:

    • 我们可以在没有 的情况下使用 AppiumDriver
    • 某些元素类型始终在使用中。如果您不定义它,则默认使用 WebElement。您可以在 Android/iOS 应用程序自动化中很好地使用 WebElements,但操作元素的功能较少。
    猜你喜欢
    • 2020-10-05
    • 2022-08-06
    • 1970-01-01
    • 1970-01-01
    • 2020-06-10
    • 1970-01-01
    • 1970-01-01
    • 2010-12-07
    • 1970-01-01
    相关资源
    最近更新 更多