public class MobileDevice extends TestObject implements IMobileGestures, IMobileClickable, IMobileKeyable
Modifier | Constructor and Description |
---|---|
protected |
MobileDevice(JtfObjectHandle handle,
Desktop desktop)
Creates a new MobileDevice with a JtfObjectHandle.
|
Modifier and Type | Method and Description |
---|---|
void |
click()
Clicks on the device at the specified coordinates.
|
void |
click(Point position)
Clicks on the device at the specified coordinates.
|
void |
closeApp()
Closes the app and releases the device, to make it available to other users.
|
void |
drag(Point start,
Point end)
Performs a drag operation between the two specified points.
|
String |
generateConnectionString()
Generates a connection string for this mobile device.
|
String |
getDeviceId()
Gets the id of the device for the current connection.
|
int |
getDisplayHeight()
Gets the height of the display in pixels.
|
DisplayOrientation |
getDisplayOrientation()
Gets the current orientation of the device.
|
int |
getDisplayWidth()
Gets the width of the display in pixels.
|
String |
getModel()
Gets the device name of the connected device.
|
MobileOperatingSystem |
getOperatingSystem()
Gets the operating system of the mobile device, Android or iOS.
|
String |
getOsVersion()
Gets the version of the operating system of the connected device.
|
boolean |
isEmulator()
Gets whether the connected device is an emulator.
|
void |
longClick()
LongClicks on the device at the specified coordinates.
|
void |
longClick(Point position)
LongClicks on the device at the specified coordinates.
|
void |
multiTouch(List<List<Point>> pointers)
Performs a multi-touch operation with the given pointers.
|
void |
pinchIn()
Performs a two-pointer gesture, where each pointer moves toward the other, from the edges to the center of this object.
|
void |
pinchIn(int percent)
Performs a two-pointer gesture, where each pointer moves toward the other, from the edges to the center of this object.
|
void |
pinchOut()
Performs a two-pointer gesture, where each pointer moves opposite across the other, from the center out towards the edges of the this object.
|
void |
pinchOut(int percent)
Performs a two-pointer gesture, where each pointer moves opposite across the other, from the center out towards the edges of the this object.
|
void |
pressBack()
Presses the back button.
|
void |
pressDelete()
Presses the delete button.
|
void |
pressEnter()
Presses the enter button.
|
void |
pressHome()
Presses the home button.
|
void |
pressKeyCode(int keyCode)
Presses a certain Android-specific key code.
|
void |
pressRecentApps()
Presses the recent apps button.
|
void |
rotate(DisplayOrientation orientation)
Simulates rotating the device screen.
|
void |
setLocation(double latitude,
double longitude)
Sets the geographic location of the device, this method only works on Android devices (physical or emulated) and iOS simulators.
|
void |
sleep()
Presses the power button if the screen is on.
|
void |
swipe(Point start,
Point end)
Performs a swipe between the two specified points.
|
void |
swipe(Point start,
Point end,
int steps)
Performs a swipe between the two specified points.
|
void |
swipe(Point start,
Point end,
int steps,
int delayBetweenSteps)
Performs a swipe between the two specified points.
|
void |
swipeDown()
Performs a down-swipe.
|
void |
swipeDown(int steps)
Performs a down-swipe.
|
void |
swipeDown(int steps,
int delayBetweenSteps)
Performs a down-swipe.
|
void |
swipeLeft()
Performs a left-swipe.
|
void |
swipeLeft(int steps)
Performs a left-swipe.
|
void |
swipeLeft(int steps,
int delayBetweenSteps)
Performs a left-swipe.
|
void |
swipeRight()
Performs a right-swipe.
|
void |
swipeRight(int steps)
Performs a right-swipe.
|
void |
swipeRight(int steps,
int delayBetweenSteps)
Performs a right-swipe.
|
void |
swipeUp()
Performs a up-swipe.
|
void |
swipeUp(int steps)
Performs a up-swipe.
|
void |
swipeUp(int steps,
int delayBetweenSteps)
Performs a up-swipe.
|
void |
swipeWithSegments(List<Point> segments)
Performs a swipe between the specified points.
|
void |
swipeWithSegments(List<Point> segments,
int steps)
Performs a swipe between the specified points.
|
void |
swipeWithSegments(List<Point> segments,
int steps,
int delayBetweenSteps)
Performs a swipe between the specified points.
|
void |
twoPointerMultiTouch(Point startPointer1,
Point endPointer1,
Point startPointer2,
Point endPointer2)
Performs a multi-touch operation with two pointers.
|
void |
twoPointerMultiTouch(Point startPointer1,
Point endPointer1,
Point startPointer2,
Point endPointer2,
int steps)
Performs a multi-touch operation with two pointers.
|
void |
twoPointerMultiTouch(Point startPointer1,
Point endPointer1,
Point startPointer2,
Point endPointer2,
int steps,
int delayBetweenSteps)
Performs a multi-touch operation with two pointers.
|
void |
typeKeys(String keys)
Sends a set of keystrokes to the object.
|
void |
typeKeys(String keys,
int delay)
Sends a set of keystrokes to the object.
|
void |
typeKeys(String keys,
int delay,
boolean ensureFocus)
Sends a set of keystrokes to the object.
|
void |
wakeUp()
Presses the power button if the screen is off.
|
captureBitmap, captureBitmap, exists, exists, generateLocator, getChildren, getDynamicMethodList, getParent, getPropertyList, getRect, getRect, getText, getValue, highlightObject, highlightObject, highlightObject, invokeMethods, textCapture, textCapture, textClick, textClick, textClick, textClick, textClick, textClick, textExists, textExists, textExists, textExists, textExists, textRectangle, textRectangle, textRectangle, textRectangle, textRectangle, waitForChildDisappearance, waitForChildDisappearance, waitForDisappearance, waitForDisappearance, waitForObject, waitForObject, waitForProperty, waitForProperty
equals, exists, find, find, findAll, findAll, getCustomTypeName, getDesktop, getHandle, getLocator, getProperty, getTypeName, hashCode, imageClick, imageClick, imageClick, imageClick, imageClick, imageClick, imageClickFile, imageClickFile, imageClickFile, imageClickFile, imageClickFile, imageClickFile, imageExists, imageExists, imageExists, imageExistsFile, imageExistsFile, imageExistsFile, imageRectangle, imageRectangle, imageRectangle, imageRectangleFile, imageRectangleFile, imageRectangleFile, invoke, preventFinalLocator, setProperty, toString
protected MobileDevice(JtfObjectHandle handle, Desktop desktop)
handle
- the handle that identifies the MobileDevicedesktop
- the desktop on which this object livespublic void click()
click
in interface IMobileClickable
public void click(Point position)
click
in interface IMobileClickable
position
- the coordinates at which to clickpublic void closeApp()
public void drag(Point start, Point end)
drag
in interface IMobileGestures
start
- the start point of the drag operationend
- the end point of the drag operationpublic String generateConnectionString()
public void longClick()
longClick
in interface IMobileClickable
public void longClick(Point position)
longClick
in interface IMobileClickable
position
- the coordinates at which to long clickpublic void multiTouch(List<List<Point>> pointers)
multiTouch
in interface IMobileGestures
pointers
- a list of pointers where every pointer contains a list of points describing it's touch pathpublic void pinchIn()
pinchIn
in interface IMobileGestures
public void pinchIn(int percent)
pinchIn
in interface IMobileGestures
percent
- percentage of the object's diagonal length for the pinch gesturepublic void pinchOut()
pinchOut
in interface IMobileGestures
public void pinchOut(int percent)
pinchOut
in interface IMobileGestures
percent
- percentage of the object's diagonal length for the pinch gesturepublic void pressBack()
public void pressDelete()
public void pressEnter()
public void pressHome()
public void pressKeyCode(int keyCode)
For additional information about the supported Android key codes, refer to the Appium documentation.
keyCode
- the desired key code to presspublic void pressRecentApps()
public void rotate(DisplayOrientation orientation)
orientation
- the desired device screen orientationpublic void setLocation(double latitude, double longitude)
latitude
- latitude of the location in degrees and minutes represented as a double valuelongitude
- longitude of the location in degrees and minutes represented as a double valuepublic void sleep()
public void swipe(Point start, Point end)
swipe
in interface IMobileGestures
start
- the start point of the swipeend
- the end point of the swipepublic void swipe(Point start, Point end, int steps)
swipe
in interface IMobileGestures
start
- the start point of the swipeend
- the end point of the swipesteps
- the number of steps between the specified points. Increase the amount of steps to increase the duration of the swipe.public void swipe(Point start, Point end, int steps, int delayBetweenSteps)
swipe
in interface IMobileGestures
start
- the start point of the swipeend
- the end point of the swipesteps
- the number of steps between the specified points. Increase the amount of steps to increase the duration of the swipe.delayBetweenSteps
- the delay in milliseconds between swipe steps. For example, when scrolling an application with a swipe operation, it depends on the swipe speed how far the application scrolls. Typically a higher delay (e.g. 300 milliseconds) creates more reproducible results.public void swipeDown()
swipeDown
in interface IMobileGestures
public void swipeDown(int steps)
swipeDown
in interface IMobileGestures
steps
- the number of steps for the swipe. Increase the amount of steps to increase the duration of the swipe.public void swipeDown(int steps, int delayBetweenSteps)
swipeDown
in interface IMobileGestures
steps
- the number of steps for the swipe. Increase the amount of steps to increase the duration of the swipe.delayBetweenSteps
- the delay in milliseconds between swipe steps. For example, when scrolling an application with a swipe operation, it depends on the swipe speed how far the application scrolls. Typically a higher delay (e.g. 300 milliseconds) creates more reproducible results.public void swipeLeft()
swipeLeft
in interface IMobileGestures
public void swipeLeft(int steps)
swipeLeft
in interface IMobileGestures
steps
- the number of steps for the swipe. Increase the amount of steps to increase the duration of the swipe.public void swipeLeft(int steps, int delayBetweenSteps)
swipeLeft
in interface IMobileGestures
steps
- the number of steps for the swipe. Increase the amount of steps to increase the duration of the swipe.delayBetweenSteps
- the delay in milliseconds between swipe steps. For example, when scrolling an application with a swipe operation, it depends on the swipe speed how far the application scrolls. Typically a higher delay (e.g. 300 milliseconds) creates more reproducible results.public void swipeRight()
swipeRight
in interface IMobileGestures
public void swipeRight(int steps)
swipeRight
in interface IMobileGestures
steps
- the number of steps for the swipe. Increase the amount of steps to increase the duration of the swipe.public void swipeRight(int steps, int delayBetweenSteps)
swipeRight
in interface IMobileGestures
steps
- the number of steps for the swipe. Increase the amount of steps to increase the duration of the swipe.delayBetweenSteps
- the delay in milliseconds between swipe steps. For example, when scrolling an application with a swipe operation, it depends on the swipe speed how far the application scrolls. Typically a higher delay (e.g. 300 milliseconds) creates more reproducible results.public void swipeUp()
swipeUp
in interface IMobileGestures
public void swipeUp(int steps)
swipeUp
in interface IMobileGestures
steps
- the number of steps for the swipe. Increase the amount of steps to increase the duration of the swipe.public void swipeUp(int steps, int delayBetweenSteps)
swipeUp
in interface IMobileGestures
steps
- the number of steps for the swipe. Increase the amount of steps to increase the duration of the swipe.delayBetweenSteps
- the delay in milliseconds between swipe steps. For example, when scrolling an application with a swipe operation, it depends on the swipe speed how far the application scrolls. Typically a higher delay (e.g. 300 milliseconds) creates more reproducible results.public void swipeWithSegments(List<Point> segments)
swipeWithSegments
in interface IMobileGestures
segments
- the points between to swipepublic void swipeWithSegments(List<Point> segments, int steps)
swipeWithSegments
in interface IMobileGestures
segments
- the points between to swipesteps
- the number of steps for the swipe. Increase the amount of steps to increase the duration of the swipe.public void swipeWithSegments(List<Point> segments, int steps, int delayBetweenSteps)
swipeWithSegments
in interface IMobileGestures
segments
- the points between to swipesteps
- the number of steps for the swipe. Increase the amount of steps to increase the duration of the swipe.delayBetweenSteps
- the delay in milliseconds between swipe steps. For example, when scrolling an application with a swipe operation, it depends on the swipe speed how far the application scrolls. Typically a higher delay (e.g. 300 milliseconds) creates more reproducible results.public void twoPointerMultiTouch(Point startPointer1, Point endPointer1, Point startPointer2, Point endPointer2)
twoPointerMultiTouch
in interface IMobileGestures
startPointer1
- the start point of the first pointerendPointer1
- the end point of the first pointerstartPointer2
- the start point of the second pointerendPointer2
- the end point of the second pointerpublic void twoPointerMultiTouch(Point startPointer1, Point endPointer1, Point startPointer2, Point endPointer2, int steps)
twoPointerMultiTouch
in interface IMobileGestures
startPointer1
- the start point of the first pointerendPointer1
- the end point of the first pointerstartPointer2
- the start point of the second pointerendPointer2
- the end point of the second pointersteps
- the number of steps between the specified points. Increase the amount of steps to increase the duration of the drag operation.public void twoPointerMultiTouch(Point startPointer1, Point endPointer1, Point startPointer2, Point endPointer2, int steps, int delayBetweenSteps)
twoPointerMultiTouch
in interface IMobileGestures
startPointer1
- the start point of the first pointerendPointer1
- the end point of the first pointerstartPointer2
- the start point of the second pointerendPointer2
- the end point of the second pointersteps
- the number of steps between the specified points. Increase the amount of steps to increase the duration of the drag operation.delayBetweenSteps
- the delay in milliseconds between swipe steps. For example, when scrolling an application with a swipe operation, it depends on the swipe speed how far the application scrolls. Typically a higher delay (e.g. 300 milliseconds) creates more reproducible results.public void typeKeys(String keys)
typeKeys
in interface IMobileKeyable
keys
- the keystrokes to typepublic void typeKeys(String keys, int delay)
typeKeys
in interface IMobileKeyable
keys
- the keystrokes to typedelay
- the delay between keystrokes in millisecondspublic void typeKeys(String keys, int delay, boolean ensureFocus)
typeKeys
in interface IMobileKeyable
keys
- the keystrokes to typedelay
- the delay between keystrokes in millisecondsensureFocus
- determines whether it should be ensured that the mobile object actually has the focus. The focus will be set with a click in the middle of the mobile object. Defaults to true
public void wakeUp()
public String getDeviceId()
public int getDisplayHeight()
public DisplayOrientation getDisplayOrientation()
public int getDisplayWidth()
public boolean isEmulator()
public String getModel()
public MobileOperatingSystem getOperatingSystem()
public String getOsVersion()
Copyright 2009-2012 Micro Focus. All Rights Reserved.