2016-08-25 92 views
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); 

是否有任何需要使用不同的驅動程序中。如果是的話,對於automationg iOS應用程序,我需要使用哪個驅動程序?

回答

1

驅動程序的使用方式有多種可能性,區別在於您希望提供多少平臺特定的功能。

對於Android,最具體的驅動程序將是AndroidDriver。 AndroidDriver擴展了AppiumDriver(你現在使用的那個),AppiumDriver擴展了RemoteWebDriver。換句話說,RemoteWebDriver具有最少的功能,並且通過驅動程序可以帶來更多選擇。

Java的客戶端的AndroidDriver:如出現在API文檔頁面AndroidDriver的 http://appium.github.io/java-client/io/appium/java_client/android/AndroidDriver.html

繼承:

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

注意AppiumDriver和AndroidDriver包括<牛逼>,它允許您選擇什麼您正在使用的MobileElements類型。訪問驅動程序的所有Android特定功能,您可能要定義<牛逼>到<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和0123一起就足夠了WebElement >(這被缺省使用)或<MobileElement>

+0

我們可以使用AppiumDriver與出

+1

一些元素類型總是在使用中。如果你沒有定義它,WebElement默認會被使用。您可以在Android/iOS應用程序自動化中使用WebElements,但使用更少的功能來操作元素。 – Domestus