Android

Methods

Methods for automating native Android applications.

Methods

DragToDisplacement (AndroidQuery[] query, TapPoint fromPoint, TapPoint displacement, int steps)

Performs a drag gesture from a point to a displacement from that point within the view specified by the query. Supports views and subclasses of: android.view.View.

Parameters

query (AndroidQuery) - Identifies an element uniquely.

fromPoint (TapPoint) - The X, Y position in the view to start the drag from. If null, defaults to center point in view. If X, or Y is negative, that value defaults to the center X, or Y of the view. If X or Y is greater than the X or Y of the view, it is still applied as is.

displacement (TapPoint) - The X, Y distance from the fromPoint to end the drag. If null, defaults to center point in view.

steps (int) - The amount of touches to generate to complete the drag. Valid values are in the range: 3 - 1000.

Example

this.ActiveDevice.Android.DragToDisplacement(elementQry, new TapPoint() { X = 10, Y = 10 }, new TapPoint() { X = -10, Y = -10 }, 20);
Me.ActiveDevice.Android.DragToDisplacement(elementQry, New TapPoint() With {.X = 10, .Y = 10 }, New TapPoint() With {.X = -10, .Y = -10 }, 20)

Back to Top

DragToPoint(AndroidQuery[] query, TapPoint fromPoint, TapPoint toPoint, int steps)

Performs a drag gesture from a point to a point within the view specified by the query. Supports views and subclasses of: android.view.View.

Parameters

query (AndroidQuery) - Identifies an element uniquely.

fromPoint (TapPoint) - The X, Y position in the view to start the drag from. If null, defaults to center point in view. If X, or Y is negative, that value defaults to the center X, or Y of the view. If X or Y is greater than the X or Y of the view, it is still applied as is.

toPoint (TapPoint) - The X, Y position in the view to end the drag. If null, equals the fromPoint. If X, or Y is negative, that value defaults to the X, or Y value of fromPoint. If X or Y is greater than the X or Y of the view, it is still applied as is.

steps (int) - The amount of touches to generate to complete the drag. Valid values are in the range: 3 - 1000.

Example

this.ActiveDevice.Android.DragToPoint(elementQry, new TapPoint() { X = 10, Y = 10 }, new TapPoint() { X = 10, Y = 10 }, 20);
Me.ActiveDevice.Android.DragToPoint(elementQry, New TapPoint() With {.X = 10, .Y = 10 }, New TapPoint() With { .X = 10, .Y = 10 }, 20)

Back to Top

ElementExists (AndroidQuery[] query)

Checks if the view specified by the query exists, and returns the result. Supports views and subclasses of: android.view.View.

Parameters

query (AndroidQuery) - Identifies an element uniquely.

Example

this.ActiveDevice.Android.ElementExists(elementQry);
Me.ActiveDevice.Android.ElementExists(elementQry)

Return Value

Gets a value indicating whether the element exists.

Back to Top

ElementVisible (AndroidQuery[] query)

Checks if the view specified by the query is visible, and returns the result. Supports views and subclasses of: android.view.View.

Parameters

query (AndroidQuery) - Identifies an element uniquely.

Example

this.ActiveDevice.Android.ElementVisible(elementQry);
Me.ActiveDevice.Android.ElementVisible(elementQry)

Return Value

Gets a value indicating whether the element is visible.

Back to Top

GetPropertyValue (AndroidQuery[] query, string propertyName)

Retrieves the value of a property from a specified view. Supports views and subclasses of: android.view.View.

Parameters

query (AndroidQuery) - Identifies an element uniquely.

propertyName (string) - The string name of the property.

Example

this.ActiveDevice.Android.GetPropertyValue(elementQry, "text");
Me.ActiveDevice.Android.GetPropertyValue(elementQry, "text")

Return Value

The String value of the property.

Back to Top

PinchIn (AndroidQuery[] query, TapPoint point, int distance, int steps)

Performs a pinch in gesture at the specified location within the view specified by the query. Supports views and subclasses of: android.view.View.

Parameters

query (AndroidQuery) - Identifies an element uniquely.

point (TapPoint) - The X, Y center point to pinch into in the view. If null, defaults to center point in view. If X, or Y is negative, that value defaults to the center X, or Y of the view. If X or Y is greater than the X or Y of the view, it is still applied as is.

distance (int) - The distance away from the point to start. Minimum value is 1.

steps (int) - The amount of touches to generate to complete the pinch in. Valid values are in the range: 3 - 1000.

Example

this.ActiveDevice.Android.PinchIn(elementQry, new TapPoint() { X = 10, Y = 10 }, 100, 50);
Me.ActiveDevice.Android.PinchIn(elementQry, New TapPoint() With {.X = 10, .Y = 10 }, 100, 50)

Back to Top

PinchOut(AndroidQuery[] query, TapPoint point, int distance, int steps)

Performs a pinch out gesture at the specified location within the view specified by the query. Supports views and subclasses of: android.view.View.

Parameters

query (AndroidQuery) - Identifies an element uniquely.

point (TapPoint) - The X, Y center point to pinch out from the view. If null, defaults to center point in view. If X, or Y is negative, that value defaults to the center X, or Y of the view. If X or Y is greater than the X or Y of the view, it is still applied as is.

distance (int) - The distance away from the point to end. Minimum value is 1.

steps (int) - The amount of touches to generate to complete the pinch out. Valid values are in the range: 3 - 1000.

Example

this.ActiveDevice.Android.PinchOut(elementQry, new TapPoint() { X = 10, Y = 10 }, 100, 50);
Me.ActiveDevice.Android.PinchOut(elementQry, New TapPoint() With { .X = 10, .Y = 10 }, 100, 50)

Back to Top

PressBackButton ()

Presses the hardware back button.

Example

this.ActiveDevice.Android.PressBackButton();
Me.ActiveDevice.Android.PressBackButton()

Back to Top

PressMenuButton ()

Presses the hardware menu button.

Example

this.ActiveDevice.Android.PressMenuButton();
Me.ActiveDevice.Android.PressMenuButton()

Back to Top

PressReturn (AndroidQuery[] query)

Presses the software keyboard return key. If the target is a SearchView, the keypress will target its internal text editing view. Supports subclasses and views of android.widget.EditText and android.widget.SearchView.

Parameters

query (AndroidQuery) - Identifies an element uniquely.

Example

this.ActiveDevice.Android.PressReturn(elementQry);
Me.ActiveDevice.Android.PressReturn(elementQry)

Back to Top

PressSearchButton ()

Presses the hardware search button.

Example

this.ActiveDevice.Android.PressSearchButton();
Me.ActiveDevice.Android.PressSearchButton()

Back to Top

Screenshot ()

Takes a screenshot of the tested UI.

Example

this.ActiveDevice.Android.Screenshot();
Me.ActiveDevice.Android.Screenshot()

Return Value

The taken screenshot as array of bytes.

Screenshot (string fileName)

Takes a screenshot of the tested UI.

Parameters

fileName (string) - The name and location to save the image at.

Example

this.ActiveDevice.Android.Screenshot("MyScreenshot.png");
Me.ActiveDevice.Android.Screenshot("MyScreenshot.png")

Back to Top

SelectRow (AndroidQuery[] query, int row, int? group = null)

Selects a row in a view specified by the query. If the target is an ExpandableListView, you must also specify a group or the row number will be applied to the group. The group will be expanded before the row is selected within the group. Supports subclasses of: android.widget.AdapterView.

Parameters

query (AndroidQuery) - Identifies an element uniquely.

row (int) - Тhe row to select. Positive numbers only.

group (int) - Тhe group containing the row to select, for ExpandableListViews. Optional. Positive numbers only.

Example

this.ActiveDevice.Android.SelectRow(elementQry, 1);
Me.ActiveDevice.Android.SelectRow(elementQry, 1)

Back to Top

SetDate (AndroidQuery[] query, DateTime date)

Sets the date on a view specified by the query. Supports views and subclasses of: android.widget.CalendarView, android.widget.DatePicker, android.widget.TimePicker.

Parameters

query (AndroidQuery) - Identifies an element uniquely.

date (DateTime) - The date to set.

Example

this.ActiveDevice.Android.SetDate(elementQry,new DateTime(2014,4,12));
Me.ActiveDevice.Android.SetDate(elementQry, New DateTime(2014, 4, 12))

Back to Top

SetText (AndroidQuery[] query, string text)

Sets the text on a view specified by the query. If the target is a SearchView, this command will target its internal text editing view, and the SearchView will be expanded before text is entered into it.

Supports subclasses and views of android.widget.EditText and android.widget.SearchView.

Parameters

query (AndroidQuery) - Identifies an element uniquely.

text (string) - Тhe text value to set on the view.

Example

this.ActiveDevice.Android.SetText(elementQry, "Test");
Me.ActiveDevice.Android.SetText(elementQry, "Test")

Back to Top

SetValue (AndroidQuery[] query, double value)

Sets the value of a view specified by the query.

Supports subclasses of android.widget.AbsSeekBar and views and subclasses of android.widget.NumberPicker.

Parameters

query (AndroidQuery) - Identifies an element uniquely.

value (double) - The value the view should be set to.

Example

this.ActiveDevice.Android.SetValue(elementQry, 60);
Me.ActiveDevice.Android.SetValue(elementQry, 60)

Back to Top

Swipe (AndroidQuery[] query, SwipeDirection direction)

Performs a swipe gesture across the view specified by the query.

Supports views and subclasses of: android.view.View.

Parameters

query (AndroidQuery) - Identifies an element uniquely.

direction (SwipeDirection) - The direction to swipe.

Example

this.ActiveDevice.Android.Swipe(elementQry, SwipeDirection.Down);
Me.ActiveDevice.Android.Swipe(elementQry, SwipeDirection.Down)

Back to Top

Tap (AndroidQuery[] query, int tapCount = 1, int tapDownDelay = 10, int tapUpDelay = 100)

Performs a tap gesture at the center of the view specified by the query.

Supports views and subclasses of: android.view.View.

Parameters

query (AndroidQuery) - Identifies an element uniquely.

tapCount (int) - How many times to tap. Optional. Default value is 1.

tapDownDelay (int) - The amount of time in milliseconds tap down should last. Optional. Default value is 10.

tapUpDelay (int) - The amount of time in milliseconds tap up should last, if multiple taps are used. Optional. Default value is 100.

Example

this.ActiveDevice.Android.Tap(buttonQry);

this.ActiveDevice.Android.Tap(buttonQry, 2, 1000, 500);
Me.ActiveDevice.Android.Tap(buttonQry)

Me.ActiveDevice.Android.Tap(buttonQry, 2, 1000, 500)

Back to Top

TapAndHold (AndroidQuery[] query)

Performs a tap-and-hold gesture at the center of the view specified by the query.

Supports views and subclasses of: android.view.View.

Parameters

query (AndroidQuery) - Identifies an element uniquely.

Example

this.ActiveDevice.Android.TapAndHold(buttonQry);
Me.ActiveDevice.Android.TapAndHold(buttonQry)

Back to Top

TapAtLocation (AndroidQuery[] query, int x, int y, int tapCount = 1)

Performs a tap gesture at the specified location within the view specified by the query.

Supports views and subclasses of: android.view.View.

Parameters

query (AndroidQuery) - Identifies an element uniquely.

x (int) - The X coordinate of the location to tap. If negative value is submitted, the value defaults to the center X of the view. If greater than the X of the view, it is still applied as is.

y (int) - The Y coordinate of the location to tap. If negative value is submitted, the value defaults to the center Y of the view. If greater than the Y of the view, it is still applied as is.

tapCount (int) - How many times to tap. Optional. Default value is 1.

Example

this.ActiveDevice.Android.TapAtLocation(buttonQry, 10, 10);

this.ActiveDevice.Android.TapAtLocation(buttonQry, 10, 10, 2);
Me.ActiveDevice.Android.TapAtLocation(buttonQry, 10, 10)

Me.ActiveDevice.Android.TapAtLocation(buttonQry, 10, 10, 2)

Back to Top

TapAtPoint (AndroidQuery[] query, TapPoint point = null, int tapCount = 1, int tapDownDelay = 10, int tapUpDelay = 100)

Performs a tap gesture at the specified point within the view specified by the query.

Supports views and subclasses of: android.view.View.

Parameters

query (AndroidQuery) - Identifies an element uniquely.

point (TapPoint) - The X, Y position to tap in the view. Optional. If null, defaults to center point in view. If X, or Y is negative, that value defaults to the center X, or Y of the view. If X or Y is greater than the X or Y of the view, it is still applied as is.

tapCount (int) - How many times to tap. Optional. Default value is 1.

tapDownDelay (int) - The amount of time in milliseconds tap down should last. Optional. Default value is 10.

tapUpDelay (int) - The amount of time in milliseconds tap up should last, if multiple taps are used. Optional. Default value is 100.

Example

this.ActiveDevice.Android.TapAtPoint(buttonQry);

this.ActiveDevice.Android.TapAtPoint(buttonQry, new TapPoint() { X=10, Y=10 }, 2, 1000, 500);
Me.ActiveDevice.Android.TapAtPoint(buttonQry)

Me.ActiveDevice.Android.TapAtPoint(buttonQry, New TapPoint() With { .X = 10, .Y = 10 }, 2, 1000, 500)

Back to Top

TapCenterLeft (AndroidQuery[] query)

Performs a tap gesture at the center-left of the view specified by the query.

Supports views and subclasses of: android.view.View.

Parameters

query (AndroidQuery) - Identifies an element uniquely.

Example

this.ActiveDevice.Android.TapCenterLeft(buttonQry);
Me.ActiveDevice.Android.TapCenterLeft(buttonQry)

Back to Top

TapCenterRight (AndroidQuery[] query)

Performs a tap gesture at the center-right of the view specified by the query.

Supports views and subclasses of: android.view.View.

Parameters

query (AndroidQuery) - Identifies an element uniquely.

Example

this.ActiveDevice.Android.TapCenterRight(buttonQry);
Me.ActiveDevice.Android.TapCenterRight(buttonQry)

Back to Top

Toggle (AndroidQuery[] query, bool toggle)

Sets the toggle state of a view specified by the query.

Supports views and subclasses of: android.widget.CompoundButton.

Parameters

query (AndroidQuery) - Identifies an element uniquely.

toggle (bool) - Тhe on/off true/false state to apply to the togglable view.

Example

this.ActiveDevice.Android.Toggle(elementQry, true);
Me.ActiveDevice.Android.Toggle(elementQry, true)

Back to Top

TwoFingerRotate (AndroidQuery[] query, TapPoint point, int angleInDegrees)

Performs a rotate gesture at the specified location within the view specified by the query.

Supports views and subclasses of: android.view.View.

Parameters

query (AndroidQuery) - Identifies an element uniquely.

point (TapPoint) - The X, Y position of origin to rotate around in the view. If null, defaults to center point in view. If X, or Y is negative, that value defaults to the center X, or Y of the view. If X or Y is greater than the X or Y of the view, it is still applied as is.

angleInDegrees (int) - The angle in degrees to rotate.

Example

this.ActiveDevice.Android.TwoFingerRotate(elementQry, new TapPoint() {X=20,Y=20 }, 180);
Me.ActiveDevice.Android.TwoFingerRotate(elementQry, New TapPoint() With { .X = 20, .Y = 20 }, 180)

Back to Top

TypeText (AndroidQuery[] query, string text)

Types the text into a view specified by the query. If the target is a SearchView, the typing will target its internal text editing view, and the SearchView will be expanded before text is entered into it.

Supports subclasses and views of android.widget.EditText and android.widget.SearchView.

Parameters

query (AndroidQuery) - Identifies an element uniquely.

text (string) -The text value to type into the view.

Example

this.ActiveDevice.Android.TypeText(elementQry, "Test");
Me.ActiveDevice.Android.TypeText(elementQry, "Test")

Back to Top

Wait (int miliseconds)

Waits an arbitrary amount of time before continuing execution.

Parameters

miliseconds (int) - The amount of time to wait in milliseconds.Positive numbers only.

Example

this.ActiveDevice.Android.Wait(1000);
Me.ActiveDevice.Android.Wait(1000)

Back to Top

WaitFor (Func <bool> func, int checkInterval, int timeout)

Executes periodic verifications against a custom condition and times out if the condition is not met.

Parameters

func (<bool> func) - The custom condition to verify.

checkInterval (int) - The interval between verification calls. Positive numbers only.

timeout (int) - The overall number of milliseconds to wait. Positive numbers only. Cannot be less than 'checkInterval'.

Example

this.ActiveDevice.Android.WaitFor(new Func<bool>(() => { Random r = new Random(); return (r.Next(2) % 2 == 0); }), 100, 200); 
Me.ActiveDevice.Android.WaitFor(New Func(Of Boolean)(Function() 
Dim r As New Random()
Return (r.[Next](2) Mod 2 = 0)

End Function), 100, 200)

Back to Top

WaitForElementExists (AndroidQuery[] query, bool exists, int checkInterval, int timeout)

Executes periodic verifications against an element query to ensure element existence or times out.

Supports views and subclasses of: android.view.View.

Parameters

query (AndroidQuery) - Identifies an element uniquely.

exists (bool) - The expected command value.

checkInterval (int) - The interval between verification calls. Positive numbers only.

timeout (int) - The overall number of milliseconds to wait. Positive numbers only. Cannot be less than 'checkInterval'.

Example

this.ActiveDevice.Android.WaitForElementExists(elementQry, true, 100, 1000);
Me.ActiveDevice.Android.WaitForElementExists(elementQry, true, 100, 1000)

Back to Top

WaitForElementVisible (AndroidQuery[] query, bool visible, int checkInterval, int timeout)

Executes periodic verifications against an element query to ensure element visibility or times out.

Supports views and subclasses of: android.view.View.

Parameters

query (AndroidQuery) - Identifies an element uniquely.

visible (bool) - The expected command value.

checkInterval (int) - The interval between verification calls. Positive numbers only.

timeout (int) - The overall number of milliseconds to wait. Positive numbers only. Cannot be less than 'checkInterval'.

Example

this.ActiveDevice.Android.WaitForElementVisible(elementQry, true, 100, 1000);
Me.ActiveDevice.Android.WaitForElementVisible(elementQry, true, 100, 1000)

Back to Top

WaitForPropertyValue (AndroidQuery[] query, string propertyName, string propertyValue, int checkInterval, int timeout)

Executes periodic verifications against an element property to ensure its value or times out.

Supports views and subclasses of: android.view.View.

Parameters

query (AndroidQuery) - Identifies an element uniquely.

propertyName (string) - The string name of the property.

propertyValue (string) - The expected property value.

checkInterval (int) - The interval between verification calls. Positive numbers only.

timeout (int) - The overall number of milliseconds to wait. Positive numbers only. Cannot be less than 'checkInterval'.

Example

this.ActiveDevice.Android.WaitForPropertyValue(elementQry, "text", "t", 100, 1000);
Me.ActiveDevice.Android.WaitForPropertyValue(elementQry, "text", "t", 100, 1000)

Back to Top

ZoomIn(AndroidQuery[] query)

Taps on the zoom in button of a ZoomControls.

Supports views and subclasses of android.widget.ZoomControls.

Parameters

query (AndroidQuery) - Identifies an element uniquely.

Example

this.ActiveDevice.Android.ZoomIn(elementQry);
Me.ActiveDevice.Android.ZoomIn(elementQry)

Back to Top

ZoomOut(AndroidQuery[] query)

Taps on the zoom out button of a ZoomControls.

Supports views and subclasses of android.widget.ZoomControls.

Parameters

query (AndroidQuery) - Identifies an element uniquely.

Example

this.ActiveDevice.Android.ZoomOut(elementQry);
Me.ActiveDevice.Android.ZoomOut(elementQry)

Back to Top