Test passcode-protected devices with Maestro
Run Maestro tests on BrowserStack App Automate real devices that have a passcode set, and enter the passcode from your flow when your app asks for it.
This feature is available only under Device Cloud Pro, Device Cloud Pro + Visual Cloud, and Enterprise Pro plans. For more details, check out our pricing page.
BrowserStack devices don’t have a passcode set by default. Some apps, such as banking apps, require a passcode-protected device as an extra layer of security.
On BrowserStack App Automate, you can set a passcode on the device for your Maestro session. BrowserStack sets the passcode when the session starts and leaves the device unlocked. When your app asks the device to authenticate, your flow types the passcode.
Supported devices and OS versions
Device passcodes work on real devices only, including private devices. The following table lists the supported OS versions:
| Platform | Supported OS versions |
|---|---|
| Android | 8.0 and later |
| iOS | 13 and later |
Prerequisites
Before you start, make sure you have the following:
- Your BrowserStack username and access key, available in the Account & Profile section of your dashboard.
- An Android app as an
.apkfile or an iOS app as an.ipafile. - A Maestro test suite zipped inside a single parent folder, as described in Prepare your Maestro test suite.
Run a Maestro test on a passcode-protected device
Complete the following steps to run a Maestro test on a passcode-protected device:
Add the passcode entry to your flow
When your app asks the device to authenticate, the device shows its passcode prompt. In your flow, enter the passcode with the inputText command. Typing the whole passcode with inputText is much faster than tapping each digit with tapOn.
On Android devices, the device passcode is 1234. After you type the passcode, press Enter to submit it.
On iOS 26, Maestro can’t detect the system passcode prompt, so an assertVisible step on the prompt fails even though inputText types the passcode. On every OS version, assert on your app’s own result after authentication, never on the passcode prompt.
Upload your app and test suite
Upload your app and your zipped Maestro test suite, then note the app_url and test_suite_url that each response returns. You need both values to start a build. For the upload commands, see Execute Maestro tests.
Start the build with a device passcode
Set enablePasscode to true when you start the build:
The following table describes the device passcode parameter:
| Parameter | Type | Description |
|---|---|---|
enablePasscode |
Boolean | Set to true to set a passcode on the device for the test session. Accepts true or false, as a Boolean or a string. Default is false. |
BrowserStack removes the passcode from the device when your session ends, so the next session on that device starts without a passcode. The passcode stays on private iOS devices whose account is set to keep it, and on private Android devices where your mobile device management (MDM) policy enforces a PIN.
Troubleshoot device passcode errors
BrowserStack checks your build request before any session starts. If the build can’t use a device passcode, BrowserStack rejects the request with one of the following errors:
| Error | Cause |
|---|---|
BROWSERSTACK_INCOMPATIBLE_OS_VERSION |
The device runs Android earlier than 8.0 or iOS earlier than 13. |
BROWSERSTACK_DEVICE_NOT_SUPPORTED |
The device doesn’t support device passcodes. Choose another device. |
BROWSERSTACK_INCOMPATIBLE_CAPABILITIES_PASSED |
The build sets realDevice to false, or combines enablePasscode with reuseDevice or reserveDevice. BrowserStack must clear the passcode between sessions, so it can’t reuse the device. |
Input parameter [enablePasscode] must have values true or false |
enablePasscode has a value other than true or false. This error returns a message instead of an error code. |
BROWSERSTACK_FEATURE_NOT_AVAILABLE_IN_CURRENT_PLAN |
Your plan doesn’t include device passcodes. |
BROWSERSTACK_INVALID_ACTION_BY_GROUP |
Device passcodes for Maestro aren’t enabled for your account yet. Contact BrowserStack Support to request access. |
All of these errors return HTTP status 422.
If you list devices with a regular expression, BrowserStack leaves out devices with unsupported OS versions instead of rejecting the build. If no listed device is left, BrowserStack rejects the build with the BROWSERSTACK_NO_DEVICE_FOUND_WITH_REQUESTED_CRITERIA error.
If BrowserStack can’t set the passcode when the session starts, it retries the session on another device. If the retry also fails, the session fails with the BROWSERSTACK_DEVICE_PASSCODE_SETUP_FAILED error and the reason Passcode Setup Failed. Retry the build. If the error persists, contact BrowserStack Support.
Related topics
- Test biometric authentication with Maestro
- Prepare your Maestro test suite
- Maestro builds API reference
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
Thank you for your valuable feedback!