RequiredElementType
- means the required type from the list of allowed types below
that implement WebElement
Instances of the defined type will be
returned via findElement* and findElements*.
Warning (!!!). Allowed types:WebElement
TouchableElement
RemoteWebElement
MobileElement
and its subclasses that designed specifically for each target mobile OS (still Android and iOS)public abstract class AppiumDriver<RequiredElementType extends org.openqa.selenium.WebElement>
extends org.openqa.selenium.remote.RemoteWebDriver
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(AppiumDriverLocalService service,
org.openqa.selenium.Capabilities desiredCapabilities) |
AppiumDriver(AppiumServiceBuilder builder,
org.openqa.selenium.Capabilities desiredCapabilities) |
AppiumDriver(org.openqa.selenium.Capabilities desiredCapabilities) |
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) |
T |
findElement(org.openqa.selenium.By by) |
T |
findElementByAccessibilityId(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<RequiredElementType> |
findElements(org.openqa.selenium.By by) |
List<RequiredElementType> |
findElementsByAccessibilityId(String using) |
List<RequiredElementType> |
findElementsByClassName(String using) |
List<RequiredElementType> |
findElementsByCssSelector(String using) |
List<RequiredElementType> |
findElementsById(String id) |
List<RequiredElementType> |
findElementsByLinkText(String using) |
List<RequiredElementType> |
findElementsByName(String using) |
List<RequiredElementType> |
findElementsByPartialLinkText(String using) |
List<RequiredElementType> |
findElementsByTagName(String using) |
List<RequiredElementType> |
findElementsByXPath(String using) |
String |
getAppStrings()
Get all defined Strings from an app for the default language
|
String |
getAppStrings(String language)
Get all defined Strings from an app for the specified language
|
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.interactions.Mouse |
getMouse()
Deprecated.
|
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.
|
abstract RequiredElementType |
scrollTo(String text)
Scroll to an element which contains the given text.
|
abstract RequiredElementType |
scrollToExact(String text)
Scroll to an element with the given text.
|
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, findElements, get, getCapabilities, getCommandExecutor, getCurrentUrl, getElementConverter, getErrorHandler, getFileDetector, getKeyboard, getPageSource, getScreenshotAs, getSessionId, getTitle, getWindowHandle, getWindowHandles, log, manage, navigate, quit, setCommandExecutor, setElementConverter, setErrorHandler, setFileDetector, setFoundBy, setLogLevel, setSessionId, startClient, startSession, startSession, stopClient, switchTo, toString
protected final String KEY_CODE
protected final String PATH
public AppiumDriver(URL remoteAddress, org.openqa.selenium.Capabilities desiredCapabilities)
public AppiumDriver(AppiumDriverLocalService service, org.openqa.selenium.Capabilities desiredCapabilities)
public AppiumDriver(AppiumServiceBuilder builder, org.openqa.selenium.Capabilities desiredCapabilities)
public AppiumDriver(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 valuepublic List<RequiredElementType> findElements(org.openqa.selenium.By by)
findElements
in interface GenericSearchContext<RequiredElementType extends org.openqa.selenium.WebElement>
findElements
in interface org.openqa.selenium.SearchContext
findElements
in interface org.openqa.selenium.WebDriver
public List<RequiredElementType> findElementsById(String id)
findElementsById
in interface GenericFindsById<RequiredElementType extends org.openqa.selenium.WebElement>
findElementsById
in interface org.openqa.selenium.internal.FindsById
public List<RequiredElementType> findElementsByLinkText(String using)
findElementsByLinkText
in interface GenericFindsByLinkText<RequiredElementType extends org.openqa.selenium.WebElement>
findElementsByLinkText
in interface org.openqa.selenium.internal.FindsByLinkText
public List<RequiredElementType> findElementsByPartialLinkText(String using)
findElementsByPartialLinkText
in interface GenericFindsByLinkText<RequiredElementType extends org.openqa.selenium.WebElement>
findElementsByPartialLinkText
in interface org.openqa.selenium.internal.FindsByLinkText
public List<RequiredElementType> findElementsByTagName(String using)
findElementsByTagName
in interface GenericFindsByTagName<RequiredElementType extends org.openqa.selenium.WebElement>
findElementsByTagName
in interface org.openqa.selenium.internal.FindsByTagName
public List<RequiredElementType> findElementsByName(String using)
findElementsByName
in interface GenericFindsByName<RequiredElementType extends org.openqa.selenium.WebElement>
findElementsByName
in interface org.openqa.selenium.internal.FindsByName
public List<RequiredElementType> findElementsByClassName(String using)
findElementsByClassName
in interface GenericFindsByClassName<RequiredElementType extends org.openqa.selenium.WebElement>
findElementsByClassName
in interface org.openqa.selenium.internal.FindsByClassName
public List<RequiredElementType> findElementsByCssSelector(String using)
findElementsByCssSelector
in interface GenericFindsByCssSelector<RequiredElementType extends org.openqa.selenium.WebElement>
findElementsByCssSelector
in interface org.openqa.selenium.internal.FindsByCssSelector
public List<RequiredElementType> findElementsByXPath(String using)
findElementsByXPath
in interface GenericFindsByXPath<RequiredElementType extends org.openqa.selenium.WebElement>
findElementsByXPath
in interface org.openqa.selenium.internal.FindsByXPath
public List<RequiredElementType> findElementsByAccessibilityId(String using)
findElementsByAccessibilityId
in interface FindsByAccessibilityId<org.openqa.selenium.WebElement>
protected 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
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
InteractsWithApps.resetApp()
public boolean isAppInstalled(String bundleId)
InteractsWithApps
bundleId
- bundleId of the appInteractsWithApps.isAppInstalled(String)
public void installApp(String appPath)
InteractsWithApps
appPath
- path to app to installInteractsWithApps.installApp(String)
public void removeApp(String bundleId)
InteractsWithApps
bundleId
- the bunble identifier (or app id) of the app to removeInteractsWithApps.removeApp(String)
public void launchApp()
InteractsWithApps
InteractsWithApps.launchApp()
public void closeApp()
InteractsWithApps
InteractsWithApps.closeApp()
public void runAppInBackground(int seconds)
InteractsWithApps
seconds
- Number of seconds to run App in backgroundInteractsWithApps.runAppInBackground(int)
public void hideKeyboard()
DeviceActionShortcuts
DeviceActionShortcuts.hideKeyboard()
public byte[] pullFile(String remotePath)
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
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
touchAction
- A TouchAction object, which contains a list of individual
touch actions to performPerformsTouchActions.performTouchAction(TouchAction)
public void performMultiTouchAction(MultiTouchAction multiAction)
PerformsTouchActions
multiAction
- the MultiTouchAction object to perform.PerformsTouchActions.performMultiTouchAction(MultiTouchAction)
public void tap(int fingers, org.openqa.selenium.WebElement element, int duration)
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
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
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)
el
- The element to pinchpublic void pinch(int x, int y)
x
- x coordinate to terminate the pinch ony
- y coordinate to terminate the pinch onpublic void zoom(org.openqa.selenium.WebElement el)
el
- The element to pinchpublic void zoom(int x, int y)
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)
public String getContext()
public void rotate(org.openqa.selenium.ScreenOrientation orientation)
public org.openqa.selenium.ScreenOrientation getOrientation()
public org.openqa.selenium.html5.Location location()
public void setLocation(org.openqa.selenium.html5.Location location)
public String getAppStrings()
HasAppStrings
HasAppStrings.getAppStrings()
public String getAppStrings(String language)
HasAppStrings
language
- strings language codeHasAppStrings.getAppStrings(String)
public URL getRemoteAddress()
protected static boolean _isNotNullOrEmpty(String str)
str
- String to check.protected static boolean _isNotNullOrEmpty(Object ob)
public abstract RequiredElementType scrollTo(String text)
ScrollsTo
public abstract RequiredElementType scrollToExact(String text)
ScrollsTo
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 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
@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 © 2015. All rights reserved.