Skip to main content
Version: 9.0.0

Device actions

Managing the behavior of your automated tests involves not only interacting with applications but also handling device-related actions. Test Maker offers a suite of device actions that empower users to install, uninstall, and manipulate applications on the target device. These actions, ranging from installApp to uninstallApp, provide flexibility and control over your testing environment. Explore the documentation below to understand how to seamlessly integrate these device actions into your test scenarios and optimize your testing process.

installApp

Installs an application on the device.

ParameterTypeDescription
pathstringThe path to the application package (APK file).
args (optional)any[]Additional arguments for the installation process.

Basic Usage

await I.installApp({
path: "./android.wdio.native.app.v1.0.8.apk",
args: [...additionalArguments], // optional
});

uninstallApp

Uninstalls a specific application from the device.

ParameterTypeDescription
id (optional)stringThe application ID to be uninstalled. If not provided, the path parameter must be used.
path (optional)stringThe path to the application package (APK file) to be uninstalled. If not provided, the id parameter must be used.
args (optional)any[]Additional arguments for the uninstallation process.

Basic Usage

await I.uninstallApp({
id: "com.wdiodemoapp", // optional
path: "./android.wdio.native.app.v1.0.8.apk", // optional
args: [...additionalArguments], // optional
});

These methods provide the capability to install and uninstall applications on the device. The installApp method installs an application using the specified APK file, while the uninstallApp method uninstalls an application based on either its ID or APK file path. Additional arguments can be provided for more control over the installation and uninstallation processes.

Note: It is recommended to either provide the id or path parameter when using the uninstallApp method to identify the application to be uninstalled.

launchApp

Method allowing to launch an application.

ParameterTypeDescription
{ id, path, type?, args? }string , string , string , any[]Application id, Application path, Application type, extra arguments.

Basic Usage

await I.launchApp(
{id: "appId",
path: "./../path-to-the-app",
type: "appType"}); // optional

closeApp

Method allowing to close a specific application.

ParameterTypeDescription
idstringApplication id.

Basic Usage

await I.closeApp("appId");

switchToApp

Method allowing to switch to a specific application.

ParameterTypeDescription
idstringApplication id.

Basic Usage

await I.switchToApp("appId");

switchContext

Method allowing to switch between contexts.

ParameterTypeDescription
idstringContext id.

Basic Usage

const newContext = await I.switchContext("contextId");

getContext

Method allowing to get the current context.

Return Value

context: string

Returns the current context as a string.

Example

const currentContext = await I.getContext();
console.log(currentContext);

This example retrieves the current context using the getContext method. The currentContext variable will contain the current context as a string.

getContexts

Method allowing to get the existing contexts.

Return Value

contexts: string[]

Returns an array of the available contexts as an array of strings.

Example

const availableContexts = await I.getContexts();
console.log(availableContexts);

This example retrieves the available contexts using the getContexts method. The availableContexts variable will contain an array of strings representing the available contexts.

getOrientation

Method allowing to get the orientation of the device.

Return Value

orientation: 'LANDSCAPE' | 'PORTRAIT'

Returns the current orientation of the device, which can be either 'LANDSCAPE' or 'PORTRAIT'.

Example

const deviceOrientation = await I.getOrientation();
console.log(deviceOrientation);

This example retrieves the current device orientation using the getOrientation method. The deviceOrientation variable will contain either 'LANDSCAPE' or 'PORTRAIT' based on the device's orientation.

setOrientation

Method allowing to set the orientation of the device.

ParameterTypeDescription
orientationLANDSCAPE / PORTRAITDevice orientation.

Basic Usage

await I.setOrientation("LANDSCAPE"); // or "PORTRAIT"

getGeoLocation

Method allowing to get the geographical location.

Return Value

location: { latitude: number; longitude: number; altitude: number; }

Returns the latitude, longitude, and altitude values of the received location.

Example

const currentLocation = await I.getGeoLocation();
console.log(currentLocation);

This example retrieves the current geographical location using the getGeoLocation method. The currentLocation object will contain latitude, longitude, and altitude values.

setGeoLocation

Method allowing to set a specific geographical location.

ParameterTypeDescription
location{latitude: number; longitude: number; altitude: number;}Define a location.

Example

const newLocation = {
latitude: 37.7749,
longitude: -122.4194,
altitude: 0,
};

await I.setGeoLocation(newLocation);