T
- the required type of class which implement WebElement
.
Instances of the defined type will be returned via findElement* and findElements*.
Warning (!!!). Allowed types:
WebElement
TouchableElement
RemoteWebElement
MobileElement
AndroidElement
public class AndroidDriver<T extends org.openqa.selenium.WebElement> extends AppiumDriver<T> implements AndroidDeviceActionShortcuts, HasNetworkConnection, PushesFiles, StartsActivity, FindsByAndroidUIAutomator<T>
org.openqa.selenium.remote.RemoteWebDriver.RemoteTargetLocator, org.openqa.selenium.remote.RemoteWebDriver.RemoteWebDriverOptions, org.openqa.selenium.remote.RemoteWebDriver.When
org.openqa.selenium.WebDriver.ImeHandler, org.openqa.selenium.WebDriver.Navigation, org.openqa.selenium.WebDriver.Options, org.openqa.selenium.WebDriver.TargetLocator, org.openqa.selenium.WebDriver.Timeouts, org.openqa.selenium.WebDriver.Window
Constructor and Description |
---|
AndroidDriver(AppiumDriverLocalService service,
org.openqa.selenium.Capabilities desiredCapabilities) |
AndroidDriver(AppiumDriverLocalService service,
org.openqa.selenium.remote.http.HttpClient.Factory httpClientFactory,
org.openqa.selenium.Capabilities desiredCapabilities) |
AndroidDriver(AppiumServiceBuilder builder,
org.openqa.selenium.Capabilities desiredCapabilities) |
AndroidDriver(AppiumServiceBuilder builder,
org.openqa.selenium.remote.http.HttpClient.Factory httpClientFactory,
org.openqa.selenium.Capabilities desiredCapabilities) |
AndroidDriver(org.openqa.selenium.Capabilities desiredCapabilities) |
AndroidDriver(org.openqa.selenium.remote.http.HttpClient.Factory httpClientFactory,
org.openqa.selenium.Capabilities desiredCapabilities) |
AndroidDriver(org.openqa.selenium.remote.HttpCommandExecutor executor,
org.openqa.selenium.Capabilities capabilities) |
AndroidDriver(URL remoteAddress,
org.openqa.selenium.Capabilities desiredCapabilities) |
AndroidDriver(URL remoteAddress,
org.openqa.selenium.remote.http.HttpClient.Factory httpClientFactory,
org.openqa.selenium.Capabilities desiredCapabilities) |
Modifier and Type | Method and Description |
---|---|
String |
currentActivity()
Get the current activity being run on the mobile device.
|
void |
endTestCoverage(String intent,
String path)
Get test-coverage data.
|
org.openqa.selenium.remote.Response |
execute(String driverCommand,
Map<String,?> parameters) |
T |
findElement(org.openqa.selenium.By by) |
T |
findElement(String by,
String using) |
T |
findElementByAccessibilityId(String using) |
T |
findElementByAndroidUIAutomator(String using) |
T |
findElementByClassName(String using) |
T |
findElementByCssSelector(String using) |
T |
findElementById(String id) |
T |
findElementByLinkText(String using) |
T |
findElementByName(String using) |
T |
findElementByPartialLinkText(String using) |
T |
findElementByTagName(String using) |
T |
findElementByXPath(String using) |
List<T> |
findElementsByAndroidUIAutomator(String using) |
Connection |
getConnection()
Get the current network settings of the device.
|
org.openqa.selenium.interactions.Mouse |
getMouse()
Deprecated.
|
NetworkConnectionSetting |
getNetworkConnection()
Deprecated.
|
void |
ignoreUnimportantViews(Boolean compress)
Set the `ignoreUnimportantViews` setting.
|
boolean |
isLocked()
Check if the device is locked.
|
void |
lockDevice()
This method locks a device.
|
void |
longPressKeyCode(int key)
Send a long key event to the device.
|
void |
longPressKeyCode(int key,
Integer metastate)
Send a long key event along with an Android metastate to an Android device.
|
void |
openNotifications()
Open the notification shade, on Android devices.
|
void |
pressKeyCode(int key)
Send a key event to the device.
|
void |
pressKeyCode(int key,
Integer metastate)
Send a key event along with an Android metastate to an Android device.
|
void |
pushFile(String remotePath,
byte[] base64Data)
Saves base64 encoded data as a file on the remote mobile device.
|
void |
pushFile(String remotePath,
File file)
Saves given file as a file on the remote mobile device.
|
T |
scrollTo(String text)
Deprecated.
|
T |
scrollToExact(String text)
Deprecated.
|
void |
setConnection(Connection connection)
Set the network connection of the device.
|
void |
setNetworkConnection(NetworkConnectionSetting connection)
Deprecated.
|
void |
startActivity(String appPackage,
String appActivity)
This method should start arbitrary activity during a test.
|
void |
startActivity(String appPackage,
String appActivity,
String appWaitPackage,
String appWaitActivity)
This method should start arbitrary activity during a test.
|
void |
startActivity(String appPackage,
String appActivity,
String appWaitPackage,
String appWaitActivity,
boolean stopApp)
This method should start arbitrary activity during a test.
|
void |
startActivity(String appPackage,
String appActivity,
String appWaitPackage,
String appWaitActivity,
String intentAction,
String intentCategory,
String intentFlags,
String intentOptionalArgs)
This method should start arbitrary activity during a test.
|
void |
startActivity(String appPackage,
String appActivity,
String appWaitPackage,
String appWaitActivity,
String intentAction,
String intentCategory,
String intentFlags,
String optionalIntentArguments,
boolean stopApp)
This method should start arbitrary activity during a test.
|
void |
swipe(int startx,
int starty,
int endx,
int endy,
int duration)
Convenience method for swiping across the screen.
|
void |
toggleLocationServices() |
void |
unlockDevice()
This method unlocks a device.
|
closeApp, context, doSwipe, execute, findElements, findElements, findElementsByAccessibilityId, findElementsByClassName, findElementsByCssSelector, findElementsById, findElementsByLinkText, findElementsByName, findElementsByPartialLinkText, findElementsByTagName, findElementsByXPath, getAppStringMap, getAppStringMap, getAppStringMap, getCommandImmutableMap, getCommandImmutableMap, getContext, getContextHandles, getDeviceTime, getExecuteMethod, getOrientation, getRemoteAddress, getSettings, hideKeyboard, installApp, isAppInstalled, launchApp, location, performMultiTouchAction, performTouchAction, pinch, pinch, pullFile, pullFolder, removeApp, resetApp, rotate, runAppInBackground, setLocation, setSetting, substituteMobilePlatform, tap, tap, zoom, zoom
close, executeAsyncScript, executeScript, get, getCapabilities, getCommandExecutor, getCurrentUrl, getElementConverter, getErrorHandler, getFileDetector, getKeyboard, getPageSource, getScreenshotAs, getSessionId, getTitle, getW3CStandardComplianceLevel, getWindowHandle, getWindowHandles, log, manage, navigate, quit, setCommandExecutor, setElementConverter, setErrorHandler, setFileDetector, setFoundBy, setLogLevel, setSessionId, startClient, startSession, startSession, stopClient, switchTo, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getDeviceTime, hideKeyboard
pullFile, pullFolder
public AndroidDriver(org.openqa.selenium.remote.HttpCommandExecutor executor, org.openqa.selenium.Capabilities capabilities)
executor
- is an instance of HttpCommandExecutor
or class that extends it. Default commands or another vendor-specific
commands may be specified there.capabilities
- take a look
at Capabilities
public AndroidDriver(URL remoteAddress, org.openqa.selenium.Capabilities desiredCapabilities)
remoteAddress
- is the address of remotely/locally
started Appium serverdesiredCapabilities
- take a look
at Capabilities
public AndroidDriver(URL remoteAddress, org.openqa.selenium.remote.http.HttpClient.Factory httpClientFactory, org.openqa.selenium.Capabilities desiredCapabilities)
remoteAddress
- is the address of remotely/locally
started Appium serverhttpClientFactory
- take a look
at HttpClient.Factory
desiredCapabilities
- take a look
at Capabilities
public AndroidDriver(AppiumDriverLocalService service, org.openqa.selenium.Capabilities desiredCapabilities)
service
- take a look
at AppiumDriverLocalService
desiredCapabilities
- take a look
at Capabilities
public AndroidDriver(AppiumDriverLocalService service, org.openqa.selenium.remote.http.HttpClient.Factory httpClientFactory, org.openqa.selenium.Capabilities desiredCapabilities)
service
- take a look
at AppiumDriverLocalService
httpClientFactory
- take a look
at HttpClient.Factory
desiredCapabilities
- take a look
at Capabilities
public AndroidDriver(AppiumServiceBuilder builder, org.openqa.selenium.Capabilities desiredCapabilities)
builder
- take a look
at AppiumServiceBuilder
desiredCapabilities
- take a look
at Capabilities
public AndroidDriver(AppiumServiceBuilder builder, org.openqa.selenium.remote.http.HttpClient.Factory httpClientFactory, org.openqa.selenium.Capabilities desiredCapabilities)
builder
- take a look
at AppiumServiceBuilder
httpClientFactory
- take a look
at HttpClient.Factory
desiredCapabilities
- take a look
at Capabilities
public AndroidDriver(org.openqa.selenium.remote.http.HttpClient.Factory httpClientFactory, org.openqa.selenium.Capabilities desiredCapabilities)
httpClientFactory
- take a look
at HttpClient.Factory
desiredCapabilities
- take a look
at Capabilities
public AndroidDriver(org.openqa.selenium.Capabilities desiredCapabilities)
desiredCapabilities
- take a look
at Capabilities
public void swipe(int startx, int starty, int endx, int endy, int duration)
TouchShortcuts
swipe
in interface TouchShortcuts
swipe
in class AppiumDriver<T extends org.openqa.selenium.WebElement>
startx
- starting x coordinate.starty
- starting y coordinate.endx
- ending x coordinate.endy
- ending y coordinate.duration
- amount of time in milliseconds for the entire swipe action to takeTouchShortcuts.swipe(int, int, int, int, int)
@Deprecated public T scrollTo(String text)
AppiumDriver.swipe(int, int, int, int, int)
MobileElement.swipe(SwipeElementDirection, int)
MobileElement.swipe(SwipeElementDirection, int, int, int)
or search for elements using MobileBy.ByAndroidUIAutomator
@Deprecated public T scrollToExact(String text)
AppiumDriver.swipe(int, int, int, int, int)
MobileElement.swipe(SwipeElementDirection, int)
MobileElement.swipe(SwipeElementDirection, int, int, int)
or search for elements using MobileBy.ByAndroidUIAutomator
scrollToExact
in interface ScrollsTo<org.openqa.selenium.WebElement>
text
- description or text of an element scroll topublic void pressKeyCode(int key)
pressKeyCode
in interface AndroidDeviceActionShortcuts
key
- code for the key pressed on the device.public void pressKeyCode(int key, Integer metastate)
AndroidDeviceActionShortcuts
pressKeyCode
in interface AndroidDeviceActionShortcuts
key
- code for the key pressed on the Android device.metastate
- metastate for the keypress.AndroidKeyCode
,
AndroidKeyMetastate
,
AndroidDeviceActionShortcuts.pressKeyCode(int, Integer).
public void longPressKeyCode(int key)
longPressKeyCode
in interface AndroidDeviceActionShortcuts
key
- code for the long key pressed on the device.public void longPressKeyCode(int key, Integer metastate)
AndroidDeviceActionShortcuts
longPressKeyCode
in interface AndroidDeviceActionShortcuts
key
- code for the long key pressed on the Android device.metastate
- metastate for the long key press.AndroidKeyCode
,
AndroidKeyMetastate
,
AndroidDeviceActionShortcuts.pressKeyCode(int, Integer)
@Deprecated public NetworkConnectionSetting getNetworkConnection()
HasNetworkConnection
HasNetworkConnection.getConnection()
instead.getNetworkConnection
in interface HasNetworkConnection
@Deprecated public void setNetworkConnection(NetworkConnectionSetting connection)
HasNetworkConnection
HasNetworkConnection.setConnection(Connection)
instead.setNetworkConnection
in interface HasNetworkConnection
connection
- The NetworkConnectionSetting configuration to use for the devicepublic void setConnection(Connection connection)
HasNetworkConnection
setConnection
in interface HasNetworkConnection
connection
- The bitmask of the desired connectionpublic Connection getConnection()
HasNetworkConnection
getConnection
in interface HasNetworkConnection
public void pushFile(String remotePath, byte[] base64Data)
PushesFiles
pushFile
in interface PushesFiles
remotePath
- Path to file to write data to on remote devicebase64Data
- Base64 encoded byte array of data to write to remote devicepublic void pushFile(String remotePath, File file) throws IOException
PushesFiles
pushFile
in interface PushesFiles
remotePath
- Path to file to write data to on remote devicefile
- is a file to write to remote deviceIOException
- when there are problems with a file or current file systempublic void startActivity(String appPackage, String appActivity, String appWaitPackage, String appWaitActivity, String intentAction, String intentCategory, String intentFlags, String optionalIntentArguments, boolean stopApp) throws IllegalArgumentException
StartsActivity
startActivity
in interface StartsActivity
appPackage
- The package containing the activity. [Required]appActivity
- The activity to start. [Required]appWaitPackage
- Automation will begin after this package starts. [Optional]appWaitActivity
- Automation will begin after this activity starts. [Optional]intentAction
- Intent action which will be used to start activity [Optional]intentCategory
- Intent category which will be used to start activity [Optional]intentFlags
- Flags that will be used to start activity [Optional]optionalIntentArguments
- Additional intent arguments that will be used to
start activity [Optional]stopApp
- If true, target app will be stopped. [Optional]IllegalArgumentException
public void startActivity(String appPackage, String appActivity, String appWaitPackage, String appWaitActivity, boolean stopApp) throws IllegalArgumentException
StartsActivity
startActivity
in interface StartsActivity
appPackage
- The package containing the activity. [Required]appActivity
- The activity to start. [Required]appWaitPackage
- Automation will begin after this package starts. [Optional]appWaitActivity
- Automation will begin after this activity starts. [Optional]stopApp
- If true, target app will be stopped. [Optional]IllegalArgumentException
public void startActivity(String appPackage, String appActivity, String appWaitPackage, String appWaitActivity) throws IllegalArgumentException
StartsActivity
startActivity
in interface StartsActivity
appPackage
- The package containing the activity. [Required]appActivity
- The activity to start. [Required]appWaitPackage
- Automation will begin after this package starts. [Optional]appWaitActivity
- Automation will begin after this activity starts. [Optional]IllegalArgumentException
public void startActivity(String appPackage, String appActivity) throws IllegalArgumentException
StartsActivity
startActivity
in interface StartsActivity
appPackage
- The package containing the activity. [Required]appActivity
- The activity to start. [Required]IllegalArgumentException
public void startActivity(String appPackage, String appActivity, String appWaitPackage, String appWaitActivity, String intentAction, String intentCategory, String intentFlags, String intentOptionalArgs) throws IllegalArgumentException
StartsActivity
startActivity
in interface StartsActivity
appPackage
- The package containing the activity. [Required]appActivity
- The activity to start. [Required]appWaitPackage
- Automation will begin after this package starts. [Optional]appWaitActivity
- Automation will begin after this activity starts. [Optional]intentAction
- Intent action which will be used to start activity [Optional]intentCategory
- Intent category which will be used to start activity [Optional]intentFlags
- Flags that will be used to start activity [Optional]intentOptionalArgs
- Additional intent arguments that will be used to
start activity [Optional]IllegalArgumentException
public void endTestCoverage(String intent, String path)
intent
- intent to broadcast.path
- path to .ec file.public String currentActivity()
public void openNotifications()
public boolean isLocked()
public void toggleLocationServices()
public void ignoreUnimportantViews(Boolean compress)
compress
- ignores unimportant views if true, doesn't ignore otherwise.public T findElementByAndroidUIAutomator(String using) throws org.openqa.selenium.WebDriverException
findElementByAndroidUIAutomator
in interface FindsByAndroidUIAutomator<T extends org.openqa.selenium.WebElement>
org.openqa.selenium.WebDriverException
- This method is not
applicable with browser/webview UI.public List<T> findElementsByAndroidUIAutomator(String using) throws org.openqa.selenium.WebDriverException
findElementsByAndroidUIAutomator
in interface FindsByAndroidUIAutomator<T extends org.openqa.selenium.WebElement>
org.openqa.selenium.WebDriverException
- This method is not applicable with browser/webview UI.public void lockDevice()
public void unlockDevice()
public org.openqa.selenium.remote.Response execute(String driverCommand, Map<String,?> parameters)
execute
in interface MobileDriver
execute
in class org.openqa.selenium.remote.RemoteWebDriver
public T findElement(org.openqa.selenium.By by)
findElement
in interface GenericSearchContext<T extends org.openqa.selenium.WebElement>
findElement
in interface org.openqa.selenium.SearchContext
findElement
in interface org.openqa.selenium.WebDriver
findElement
in class org.openqa.selenium.remote.RemoteWebDriver
public T findElement(String by, String using)
findElement
in class org.openqa.selenium.remote.RemoteWebDriver
public T findElementById(String id)
findElementById
in interface GenericFindsById<T extends org.openqa.selenium.WebElement>
findElementById
in interface org.openqa.selenium.internal.FindsById
findElementById
in class org.openqa.selenium.remote.RemoteWebDriver
public T findElementByLinkText(String using) throws org.openqa.selenium.WebDriverException
findElementByLinkText
in interface GenericFindsByLinkText<T extends org.openqa.selenium.WebElement>
findElementByLinkText
in interface org.openqa.selenium.internal.FindsByLinkText
findElementByLinkText
in class org.openqa.selenium.remote.RemoteWebDriver
org.openqa.selenium.WebDriverException
- his method doesn't work against native app UI.public T findElementByPartialLinkText(String using) throws org.openqa.selenium.WebDriverException
findElementByPartialLinkText
in interface GenericFindsByLinkText<T extends org.openqa.selenium.WebElement>
findElementByPartialLinkText
in interface org.openqa.selenium.internal.FindsByLinkText
findElementByPartialLinkText
in class org.openqa.selenium.remote.RemoteWebDriver
org.openqa.selenium.WebDriverException
- his method doesn't work against native app UI.public T findElementByTagName(String using)
findElementByTagName
in interface GenericFindsByTagName<T extends org.openqa.selenium.WebElement>
findElementByTagName
in interface org.openqa.selenium.internal.FindsByTagName
findElementByTagName
in class org.openqa.selenium.remote.RemoteWebDriver
public T findElementByName(String using)
findElementByName
in interface GenericFindsByName<T extends org.openqa.selenium.WebElement>
findElementByName
in interface org.openqa.selenium.internal.FindsByName
findElementByName
in class org.openqa.selenium.remote.RemoteWebDriver
public T findElementByClassName(String using)
findElementByClassName
in interface GenericFindsByClassName<T extends org.openqa.selenium.WebElement>
findElementByClassName
in interface org.openqa.selenium.internal.FindsByClassName
findElementByClassName
in class org.openqa.selenium.remote.RemoteWebDriver
public T findElementByCssSelector(String using) throws org.openqa.selenium.WebDriverException
findElementByCssSelector
in interface GenericFindsByCssSelector<T extends org.openqa.selenium.WebElement>
findElementByCssSelector
in interface org.openqa.selenium.internal.FindsByCssSelector
findElementByCssSelector
in class org.openqa.selenium.remote.RemoteWebDriver
org.openqa.selenium.WebDriverException
- his method doesn't work against native app UI.public T findElementByXPath(String using)
findElementByXPath
in interface GenericFindsByXPath<T extends org.openqa.selenium.WebElement>
findElementByXPath
in interface org.openqa.selenium.internal.FindsByXPath
findElementByXPath
in class org.openqa.selenium.remote.RemoteWebDriver
public T findElementByAccessibilityId(String using) throws org.openqa.selenium.WebDriverException
findElementByAccessibilityId
in interface FindsByAccessibilityId<org.openqa.selenium.WebElement>
org.openqa.selenium.WebDriverException
- This method is not applicable with browser/webview UI.@Deprecated public org.openqa.selenium.interactions.Mouse getMouse()
getMouse
in interface org.openqa.selenium.interactions.HasInputDevices
getMouse
in class org.openqa.selenium.remote.RemoteWebDriver
Copyright © 2016. All rights reserved.