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
elementElementThe element to create the adapter for.
Exceptions
- NullReferenceException
If
elementisnull.- 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
enabledboolEnables 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
enabledboolEnables or disables the network interface.
forMillisecondsintGive 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
elementElementThe element to convert.
Returns
- AndroidApp
The AndroidApp.
Exceptions
- ArgumentNullException
If
elementisnull.- 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
pathstringThe search path.
Returns
- AndroidApp
The AndroidApp.
Remarks
The DefaultSearchTimeout is used to search for the specified path.
Exceptions
- ArgumentNullException
If
pathisnull.- RxPathException
If the specified
pathis 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
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
pathstringFile 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
AppstringThe 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.
ResetInitialStateboolIndicates 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
elementElementThe element to convert.
Returns
- AndroidApp
The AndroidApp.
Exceptions
- ArgumentNullException
If
elementisnull.- 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
pathstringThe search path.
Returns
- AndroidApp
The AndroidApp.
Remarks
The DefaultSearchTimeout is used to search for the specified path.
Exceptions
- ArgumentNullException
If
pathisnull.- RxPathException
If the specified
pathis not valid.- ElementNotFoundException
If no element is found.
- CapabilityNotSupportedException
If the element does not support the capabilities required by this adapter.