Table of Contents

Class AndroidApp

Namespace
Ranorex
Assembly
Ranorex.Plugin.Mobile.dll

A capability that adds additional attributes to elements that represent a mobile application.

public class AndroidApp : Adapter, IAdapter
Inheritance
AndroidApp
Implements
Inherited Members

Constructors

AndroidApp()

Creates a new AndroidApp adapter instance. This constructor is used internally by the Ranorex Core Framework for performance issues!

protected AndroidApp()

AndroidApp(Element)

Creates a new AndroidApp adapter instance.

public AndroidApp(Element element)

Parameters

element Element

The element to create the adapter for.

Exceptions

NullReferenceException

If element is null.

CapabilityNotSupportedException

If the element does not support the capabilities required by this adapter.

Properties

RequiredCapabilities

Capabilities required by the adapter implementation.

protected override string[] RequiredCapabilities { get; }

Property Value

string[]

Methods

CloseApplication()

Closes the specified application on the corresponding device.

public virtual void CloseApplication()

Exceptions

ActionFailedException

Thrown if invoking the action failed.

EnableBluetooth(bool)

Enable or disable bluetooth interface of the device.

public virtual void EnableBluetooth(bool enabled)

Parameters

enabled bool

Enables or disables the bluetooth interface.

Exceptions

ActionFailedException

Thrown if invoking the action failed.

EnableWifi(bool, int)

Enable or disable network interface of the device. Give a optional time to switch back to the initial state.

public virtual void EnableWifi(bool enabled, int forMilliseconds)

Parameters

enabled bool

Enables or disables the network interface.

forMilliseconds int

Give an optional time for the state change. Use -1 to indicate that the state switch should be permanent.

Exceptions

ActionFailedException

Thrown if invoking the action failed.

FetchStartableApps()

Gets a list of application identifiers that can be used with Host.RunMobileApp to start an app on the device from within the Ranorex system.

public virtual void FetchStartableApps()

Exceptions

ActionFailedException

Thrown if invoking the action failed.

FromElement(Element)

Converts an Element to an instance of this class.

public static AndroidApp FromElement(Element element)

Parameters

element Element

The element to convert.

Returns

AndroidApp

The AndroidApp.

Exceptions

ArgumentNullException

If element is null.

CapabilityNotSupportedException

If the element does not support the capabilities required by this adapter.

FromPath(string)

Converts a string to an instance of this class by searching the root.

public static AndroidApp FromPath(string path)

Parameters

path string

The search path.

Returns

AndroidApp

The AndroidApp.

Remarks

The DefaultSearchTimeout is used to search for the specified path.

Exceptions

ArgumentNullException

If path is null.

RxPathException

If the specified path is not valid.

ElementNotFoundException

If no element is found.

CapabilityNotSupportedException

If the element does not support the capabilities required by this adapter.

GetCalls()

Gets call information from the device.

public virtual PhoneCallCollection GetCalls()

Returns

PhoneCallCollection

Call information from the device.

Exceptions

ActionFailedException

Thrown if invoking the action failed.

GetContacts()

Gets contact information from device

public virtual ContactCollection GetContacts()

Returns

ContactCollection

Contact information from device

Exceptions

ActionFailedException

Thrown if invoking the action failed.

GetDeviceInfo()

Gets system information about the android device.

public virtual AndroidDeviceInfo GetDeviceInfo()

Returns

AndroidDeviceInfo

System information from android device.

Exceptions

ActionFailedException

Thrown if invoking the action failed.

GetSms()

Reads SMS from the device.

public virtual SmsCollection GetSms()

Returns

SmsCollection

List of SMS from the device.

Exceptions

ActionFailedException

Thrown if invoking the action failed.

MockGps(double, double)

Sets the GPS location to a specific latitude and longitude. Please enable (Settings -> Developer options) "Allow mock locations" and enable (Settings -> Location access) "GPS satellites" and disable "WiFi location".

public virtual void MockGps(double latitude, double longitude)

Parameters

latitude double

Latitude in decimal format.

longitude double

Longitude in decimal format.

Exceptions

ActionFailedException

Thrown if invoking the action failed.

MockGpsOff()

Disables mock location on device.

public virtual void MockGpsOff()

Exceptions

ActionFailedException

Thrown if invoking the action failed.

PressBackKey()

Presses the hardware back key on the device.

public virtual void PressBackKey()

Exceptions

ActionFailedException

Thrown if invoking the action failed.

PressMenuKey()

Presses the hardware back key on the device.

public virtual void PressMenuKey()

Exceptions

ActionFailedException

Thrown if invoking the action failed.

SaveAdbLog(string)

Fetches the log of an Android device and saves it into a text file.

public virtual void SaveAdbLog(string path)

Parameters

path string

File path

Exceptions

ActionFailedException

Thrown if invoking the action failed.

StartApp(string, bool)

Starts an app on the device.

public virtual string StartApp(string App, bool ResetInitialState)

Parameters

App string

The package name of the application to start e.g. 'ranorex.services'. Use the FetchStartableApps command to get a list of valid values from the device.

ResetInitialState bool

Indicates if the app should be restarted on launch or just brought to the foreground in case the app is already running.

Returns

string

The value that will be returned by the action invocation.

Exceptions

ActionFailedException

Thrown if invoking the action failed.

Operators

implicit operator AndroidApp(Element)

Implicitly converts an Element to an instance of this class.

public static implicit operator AndroidApp(Element element)

Parameters

element Element

The element to convert.

Returns

AndroidApp

The AndroidApp.

Exceptions

ArgumentNullException

If element is null.

CapabilityNotSupportedException

If the element does not support the capabilities required by this adapter.

implicit operator AndroidApp(string)

Implicitly converts a string to an instance of this class by searching the root.

public static implicit operator AndroidApp(string path)

Parameters

path string

The search path.

Returns

AndroidApp

The AndroidApp.

Remarks

The DefaultSearchTimeout is used to search for the specified path.

Exceptions

ArgumentNullException

If path is null.

RxPathException

If the specified path is not valid.

ElementNotFoundException

If no element is found.

CapabilityNotSupportedException

If the element does not support the capabilities required by this adapter.