public abstract class AppiumDriver extends org.openqa.selenium.remote.RemoteWebDriver implements MobileDriver, org.openqa.selenium.ContextAware, org.openqa.selenium.Rotatable, FindsByAccessibilityId, org.openqa.selenium.html5.LocationContext, DeviceActionShortcuts, TouchShortcuts, InteractsWithFiles, InteractsWithApps, ScrollsTo
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
Modifier and Type | Field and Description |
---|---|
protected String |
KEY_CODE |
protected String |
PATH |
Constructor and Description |
---|
AppiumDriver(URL remoteAddress,
org.openqa.selenium.Capabilities desiredCapabilities) |
Modifier and Type | Method and Description |
---|---|
protected static boolean |
_isNotNullOrEmpty(Object ob) |
protected static boolean |
_isNotNullOrEmpty(String str)
Checks if a string is null, empty, or whitespace.
|
void |
closeApp()
Close the app which was provided in the capabilities at session creation
|
org.openqa.selenium.WebDriver |
context(String name) |
protected org.openqa.selenium.remote.Response |
execute(String command) |
org.openqa.selenium.remote.Response |
execute(String driverCommand,
Map<String,?> parameters) |
org.openqa.selenium.WebElement |
findElementByAccessibilityId(String using) |
List<org.openqa.selenium.WebElement> |
findElementsByAccessibilityId(String using) |
protected static com.google.common.collect.ImmutableMap<String,Object> |
getCommandImmutableMap(String[] params,
Object[] values) |
protected static com.google.common.collect.ImmutableMap<String,Object> |
getCommandImmutableMap(String param,
Object value) |
String |
getContext() |
Set<String> |
getContextHandles() |
org.openqa.selenium.remote.ExecuteMethod |
getExecuteMethod() |
org.openqa.selenium.ScreenOrientation |
getOrientation() |
URL |
getRemoteAddress() |
com.google.gson.JsonObject |
getSettings()
Get settings stored for this test session It's probably better to use a
convenience function, rather than use this function directly.
|
void |
hideKeyboard()
Hides the keyboard if it is showing.
|
void |
installApp(String appPath)
Install an app on the mobile device
|
boolean |
isAppInstalled(String bundleId)
Checks if an app is installed on the device
|
void |
launchApp()
Launch the app which was provided in the capabilities at session creation
|
org.openqa.selenium.html5.Location |
location() |
void |
lockScreen(int seconds)
Lock the device (bring it to the lock screen) for a given number of
seconds
|
void |
performMultiTouchAction(MultiTouchAction multiAction)
Performs multiple TouchAction gestures at the same time, to simulate
multiple fingers/touch inputs.
|
TouchAction |
performTouchAction(TouchAction touchAction)
Performs a chain of touch actions, which together can be considered an
entire gesture.
|
void |
pinch(int x,
int y)
Convenience method for pinching an element on the screen.
|
void |
pinch(org.openqa.selenium.WebElement el)
Convenience method for pinching an element on the screen.
|
byte[] |
pullFile(String remotePath) |
byte[] |
pullFolder(String remotePath)
Pull a folder from the simulator/device.
|
void |
removeApp(String bundleId)
Remove the specified app from the device (uninstall)
|
void |
resetApp()
Reset the currently running app for this session
|
void |
rotate(org.openqa.selenium.ScreenOrientation orientation) |
void |
runAppInBackground(int seconds)
Runs the current app as a background app for the number of seconds
requested.
|
void |
sendKeyEvent(int key)
Send a key event to the device
|
void |
setLocation(org.openqa.selenium.html5.Location location) |
protected void |
setSetting(AppiumSetting setting,
Object value)
Set a setting for this test session It's probably better to use a
convenience function, rather than use this function directly.
|
protected static org.openqa.selenium.Capabilities |
substituteMobilePlatform(org.openqa.selenium.Capabilities originalCapabilities,
String newPlatform) |
void |
swipe(int startx,
int starty,
int endx,
int endy,
int duration)
Convenience method for swiping across the screen
|
void |
tap(int fingers,
int x,
int y,
int duration)
Convenience method for tapping a position on the screen
|
void |
tap(int fingers,
org.openqa.selenium.WebElement element,
int duration)
Convenience method for tapping the center of an element on the screen
|
void |
zoom(int x,
int y)
Convenience method for "zooming in" on an element on the screen.
|
void |
zoom(org.openqa.selenium.WebElement el)
Convenience method for "zooming in" on an element on the screen.
|
close, executeAsyncScript, executeScript, findElement, findElement, findElementByClassName, findElementByCssSelector, findElementById, findElementByLinkText, findElementByName, findElementByPartialLinkText, findElementByTagName, findElementByXPath, findElements, findElements, findElementsByClassName, findElementsByCssSelector, findElementsById, findElementsByLinkText, findElementsByName, findElementsByPartialLinkText, findElementsByTagName, findElementsByXPath, get, getCapabilities, getCommandExecutor, getCurrentUrl, getElementConverter, getErrorHandler, getFileDetector, getKeyboard, getMouse, getPageSource, getRemoteStatus, getScreenshotAs, getSessionId, getTitle, 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
close, findElement, findElements, get, getCurrentUrl, getPageSource, getTitle, getWindowHandle, getWindowHandles, manage, navigate, quit, switchTo
scrollTo, scrollToExact
protected final String KEY_CODE
protected final String PATH
public AppiumDriver(URL remoteAddress, org.openqa.selenium.Capabilities desiredCapabilities)
protected static org.openqa.selenium.Capabilities substituteMobilePlatform(org.openqa.selenium.Capabilities originalCapabilities, String newPlatform)
originalCapabilities
- the given Capabilities
newPlatform
- a MobileCapabilityType.PLATFORM_NAME
value which has
to be set upCapabilities
with changed mobile platform valueprotected static com.google.common.collect.ImmutableMap<String,Object> getCommandImmutableMap(String param, Object value)
param
- is a parameter namevalue
- is the parameter valueImmutableMap
protected static com.google.common.collect.ImmutableMap<String,Object> getCommandImmutableMap(String[] params, Object[] values)
params
- is the array with parameter namesvalues
- is the array with parameter valuesImmutableMap
public org.openqa.selenium.remote.Response execute(String driverCommand, Map<String,?> parameters)
execute
in interface MobileDriver
execute
in class org.openqa.selenium.remote.RemoteWebDriver
protected org.openqa.selenium.remote.Response execute(String command)
execute
in class org.openqa.selenium.remote.RemoteWebDriver
public org.openqa.selenium.remote.ExecuteMethod getExecuteMethod()
getExecuteMethod
in class org.openqa.selenium.remote.RemoteWebDriver
public void resetApp()
InteractsWithApps
resetApp
in interface InteractsWithApps
InteractsWithApps.resetApp()
public boolean isAppInstalled(String bundleId)
InteractsWithApps
isAppInstalled
in interface InteractsWithApps
bundleId
- bundleId of the appInteractsWithApps.isAppInstalled(String)
public void installApp(String appPath)
InteractsWithApps
installApp
in interface InteractsWithApps
appPath
- path to app to installInteractsWithApps.installApp(String)
public void removeApp(String bundleId)
InteractsWithApps
removeApp
in interface InteractsWithApps
bundleId
- the bunble identifier (or app id) of the app to removeInteractsWithApps.removeApp(String)
public void launchApp()
InteractsWithApps
launchApp
in interface InteractsWithApps
InteractsWithApps.launchApp()
public void closeApp()
InteractsWithApps
closeApp
in interface InteractsWithApps
InteractsWithApps.closeApp()
public void runAppInBackground(int seconds)
InteractsWithApps
runAppInBackground
in interface InteractsWithApps
seconds
- Number of seconds to run App in backgroundInteractsWithApps.runAppInBackground(int)
public void sendKeyEvent(int key)
sendKeyEvent
in interface DeviceActionShortcuts
key
- code for the key pressed on the deviceAndroidKeyCode
,
IOSKeyCode
public void hideKeyboard()
DeviceActionShortcuts
hideKeyboard
in interface DeviceActionShortcuts
DeviceActionShortcuts.hideKeyboard()
public byte[] pullFile(String remotePath)
pullFile
in interface InteractsWithFiles
remotePath
- On Android and iOS, this is either the path to the file
(relative to the root of the app's file system). On iOS only,
if path starts with /AppName.app, which will be replaced with
the application's .app directoryInteractsWithFiles.pullFile(String)
public byte[] pullFolder(String remotePath)
InteractsWithFiles
pullFolder
in interface InteractsWithFiles
remotePath
- On Android and iOS, this is either the path to the file
(relative to the root of the app's file system). On iOS only,
if path starts with /AppName.app, which will be replaced with
the application's .app directoryInteractsWithFiles.pullFolder(String)
public TouchAction performTouchAction(TouchAction touchAction)
PerformsTouchActions
performTouchAction
in interface PerformsTouchActions
touchAction
- A TouchAction object, which contains a list of individual
touch actions to performPerformsTouchActions.performTouchAction(TouchAction)
public void performMultiTouchAction(MultiTouchAction multiAction)
PerformsTouchActions
performMultiTouchAction
in interface PerformsTouchActions
multiAction
- the MultiTouchAction object to perform.PerformsTouchActions.performMultiTouchAction(MultiTouchAction)
public void tap(int fingers, org.openqa.selenium.WebElement element, int duration)
TouchShortcuts
tap
in interface TouchShortcuts
fingers
- number of fingers/appendages to tap withelement
- element to tapduration
- how long between pressing down, and lifting fingers/appendagesTouchShortcuts.tap(int, WebElement, int)
public void tap(int fingers, int x, int y, int duration)
TouchShortcuts
tap
in interface TouchShortcuts
fingers
- number of fingers/appendages to tap withx
- x coordinatey
- y coordinateTouchShortcuts.tap(int, int, int, int)
public void swipe(int startx, int starty, int endx, int endy, int duration)
TouchShortcuts
swipe
in interface TouchShortcuts
startx
- starting x coordinatestarty
- starting y coordinateendx
- ending x coordinateendy
- ending y coordinateduration
- amount of time in milliseconds for the entire swipe action to
takeTouchShortcuts.swipe(int, int, int, int, int)
public void pinch(org.openqa.selenium.WebElement el)
pinch
in interface TouchShortcuts
el
- The element to pinchpublic void pinch(int x, int y)
pinch
in interface TouchShortcuts
x
- x coordinate to terminate the pinch ony
- y coordinate to terminate the pinch onpublic void zoom(org.openqa.selenium.WebElement el)
zoom
in interface TouchShortcuts
el
- The element to pinchpublic void zoom(int x, int y)
zoom
in interface TouchShortcuts
x
- x coordinate to start zoom ony
- y coordinate to start zoom onpublic com.google.gson.JsonObject getSettings()
protected void setSetting(AppiumSetting setting, Object value)
setting
- AppiumSetting you wish to setvalue
- value of the settingpublic void lockScreen(int seconds)
seconds
- number of seconds to lock the screen forpublic org.openqa.selenium.WebDriver context(String name)
context
in interface org.openqa.selenium.ContextAware
public Set<String> getContextHandles()
getContextHandles
in interface org.openqa.selenium.ContextAware
public String getContext()
getContext
in interface org.openqa.selenium.ContextAware
public void rotate(org.openqa.selenium.ScreenOrientation orientation)
rotate
in interface org.openqa.selenium.Rotatable
public org.openqa.selenium.ScreenOrientation getOrientation()
getOrientation
in interface org.openqa.selenium.Rotatable
public org.openqa.selenium.WebElement findElementByAccessibilityId(String using)
findElementByAccessibilityId
in interface FindsByAccessibilityId
public List<org.openqa.selenium.WebElement> findElementsByAccessibilityId(String using)
findElementsByAccessibilityId
in interface FindsByAccessibilityId
public org.openqa.selenium.html5.Location location()
location
in interface org.openqa.selenium.html5.LocationContext
public void setLocation(org.openqa.selenium.html5.Location location)
setLocation
in interface org.openqa.selenium.html5.LocationContext
public URL getRemoteAddress()
protected static boolean _isNotNullOrEmpty(String str)
str
- String to check.protected static boolean _isNotNullOrEmpty(Object ob)
Copyright © 2014. All rights reserved.