Skip to main content

Configuration

The Mobilewright engine is set up in wdio.conf.ts with the automationProtocol option, the connection options of WebdriverIO for the mobilecli server, and capabilities with the mobilecli: prefix. This page lists every option. For a first run, start with the quick start.

The engine needs mobilecli, which you install yourself and start with mobilecli server start before a test run. See Prerequisites.

wdio.conf.ts
import path from 'node:path'

export const config: WebdriverIO.Config = {
// ...
automationProtocol: '@wdio/mobilecli-driver',
hostname: 'localhost',
port: 12000,
capabilities: [{
platformName: 'iOS',
'mobilecli:udid': '5B9D4A2E-6C3F-4E8A-9B1D-2F7C8E0A4D6B',
'mobilecli:app': path.resolve(import.meta.dirname, 'apps', 'MyApp.app.zip'),
'mobilecli:options': {
actionTimeout: 10000
}
}]
}

Server address​

The engine sends its commands to the mobilecli server that mobilecli server start runs. Run the server on the machine that your emulators, simulators or devices are connected to.

info

Device clouds are not supported yet: support for them is in progress.

The address comes from the connection options of WebdriverIO:

OptionDefaultDescription
protocolhttphttp or https.
hostnamelocalhostThe host of the mobilecli server.
port12000The port of the mobilecli server.
path/A path in front of /rpc, for example when a proxy serves the server under a path.
headersHeaders sent with every request, for example the Authorization header of a proxy in front of the server.
connectionRetryTimeout120000How long one call to the server can take, in ms.

Set hostname and port in your config even when they match the defaults, so it is clear where the commands go.

Capabilities​

CapabilityDescription
platformNameiOS or Android. Optional: the session takes the platform from the device. If it is set and the device is of the other platform, the session does not start.
mobilecli:udidThe id of the device, as listed by mobilecli devices. Optional when exactly one device is online.
mobilecli:appThe app to install and start when the session starts, see Apps. Optional.
mobilecli:optionsThe settings of the engine, see Settings. Optional.

The mobilecli: capabilities use the same names as their Appium counterparts (appium:udid, appium:app), so a capability is easy to move from one protocol to the other. They are typed in @wdio/types, so you get autocompletion in wdio.conf.ts without an extra import.

Choose a device​

Without mobilecli:udid, the session uses the only device that is online. With more than one device online, the session does not start until you set mobilecli:udid:

mobilecli devices

With alwaysMatch and firstMatch, the session starts with the first firstMatch entry that matches a device.

Run on more than one device​

The engine does not divide devices over workers yet. To run test files in parallel, give each device its own capability with its own mobilecli:udid, and run one worker per device:

wdio.conf.ts
export const config: WebdriverIO.Config = {
// ...
capabilities: [{
platformName: 'Android',
'mobilecli:udid': 'emulator-5554',
'wdio:maxInstances': 1
}, {
platformName: 'iOS',
'mobilecli:udid': '5B9D4A2E-6C3F-4E8A-9B1D-2F7C8E0A4D6B',
'wdio:maxInstances': 1
}]
}

Apps​

With mobilecli:app, the session installs the app on the device and starts it, so the test starts in the app. Without it, the session starts with whatever is on the screen of the device.

DeviceApp file
Android device or emulator.apk
iOS simulator.app folder, or a .zip with the .app folder in it
iOS device.ipa

The value is a path on the machine where the mobilecli server runs. Use an absolute path: the server resolves a relative path from the folder it was started in.

wdio.conf.ts
import path from 'node:path'

export const config: WebdriverIO.Config = {
// ...
capabilities: [{
platformName: 'Android',
'mobilecli:app': path.resolve(import.meta.dirname, 'apps', 'android.wdio.native.app.v2.2.0.apk')
}]
}

An app that is already installed is replaced and keeps its data. If the app can not be installed or started, the session does not start, and the error has the reason that mobilecli gives.

After the start, the session waits until the app is in the foreground. It checks every 100 ms, for 20 seconds by default. If the app is not in the foreground by then, the session does not start:

The app com.wdiodemoapp was started, but it was not in the foreground within 20000ms (in the foreground: com.android.launcher). Give it more time with "appLaunchTimeout" in the capability "mobilecli:options".

A real device can need more time than a simulator or an emulator:

wdio.conf.ts
export const config: WebdriverIO.Config = {
// ...
capabilities: [{
platformName: 'iOS',
'mobilecli:app': '/Users/me/apps/MyApp.ipa',
'mobilecli:options': { appLaunchTimeout: 60000 }
}]
}

On some Android devices mobilecli can not tell which app is in the foreground, although the app did start. The session then logs this warning and starts:

Could not check that com.wdiodemoapp is in the foreground, a known problem of mobilecli on some Android devices. The session goes on.
info

Installing, starting or stopping an app during a test is not supported yet. Start the app with mobilecli:app, and run tests that need to restart or switch apps with Appium.

Settings​

The capability mobilecli:options changes how long the engine waits and how it reads the screen. Every setting is optional. All values are in milliseconds, except maxSearchesPerScreen.

wdio.conf.ts
export const config: WebdriverIO.Config = {
// ...
capabilities: [{
platformName: 'iOS',
'mobilecli:options': {
actionTimeout: 10000,
installTimeout: 300000
}
}]
}
SettingDefaultDescription
actionTimeoutwaitforTimeout (5000)How long a command waits until it can use its element, see Waiting and timeouts.
pollIntervalwaitforInterval (100)How long a command waits between two reads of the screen while it waits for its element.
stabilityDelay50An element is tapped when two reads of the screen show it at the same place. This is the time between these two reads.
stabilityWindow1000How long a read of the screen counts as the first of these two reads.
screenFreshTime100How long a read of the screen is reused instead of a new one, as long as nothing was done on the screen. Finds and reads in a row then share one read, which makes a test faster. With 0, every find and every command reads the screen itself.
maxSearchesPerScreen2How often a find can search for the same selector in one read of the screen. WebdriverIO searches a second time right after it waited for an element.
focusTimeout3000How long addValue() waits until the element that it tapped has the focus, before it types.
keyboardTimeout60000How long hideKeyboard() can take.
installTimeout190000How long installing the app of mobilecli:app can take.
appLaunchTimeout20000How long the session waits until the app of mobilecli:app is in the foreground, see Apps.

A setting that the engine does not know, or a value that is not a number of 0 or more, stops the session from starting.

Sessions​

mobilecli has no sessions. Starting a session connects to the server and to the device. Ending it only disconnects: the device, the app and the server keep running.

info

browser.reloadSession() and attaching to a running session are not supported yet.

Welcome! How can I help?

WebdriverIO AI Copilot