Skip to main content
🚀 Self Healing AI Agent now live in App Automate! Auto-fix flaky tests instantly with zero code changes. Enable now!
No Result Found
Get your setup working faster. Join our Discord for optimisation tips from elite testers. Join our DiscordJoin our Discord

Test using passcode-protected devices

A guide for use cases that need passcode-protected devices to automate tests on BrowserStack App Automate.

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.

For certain use cases, you might need to perform tests on devices that are passcode-protected. Some apps that deal with sensitive data, such as banking apps, require devices to be protected with a passcode as a layer of security.

Since BrowserStack remote devices are not passcode-protected as a default, App Automate provides the capability to use in the test script for getting access to passcode-protected devices.

In this guide, you’ll learn:

Supported OS versions

Currently, this feature is supported on the following OS versions:

  • Android: version 8.0 and above
  • iOS: version 13.0 and above

Set the capability

Use the passcode capability to enable the passcode protection in your test scripts:

If you are using BrowserStack SDK, you can set the following capability within the browserstack.yml file:

Capability Description Values
enablePasscode Use passcode-protected devices to run tests. true, false
Default: false
browserstack.yml
Copy icon Copy

Sample code to unlock device

To unlock a device during testing, if required, use the information in the following tabs.

Use the following Appium command to unlock a device during test execution.

The supporting capabilities for the unlock appium command, namely unlockType and unlockKey, are passed automatically to your tests by BrowserStack.

// your test script goes here
driver.pressKey(new KeyEvent(AndroidKey.DIGIT_1));
driver.pressKey(new KeyEvent(AndroidKey.DIGIT_2));
driver.pressKey(new KeyEvent(AndroidKey.DIGIT_3));
driver.pressKey(new KeyEvent(AndroidKey.DIGIT_4));
driver.pressKey(new KeyEvent(AndroidKey.ENTER));

For Android devices, the unlock pin is 1234.

You can also write an automation code that taps and sets the device passcode to 1234 to unlock the device.

Need some help?

If you need any help with this feature, get in touch with us.

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

Is this page helping you?

Yes
No

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!

Talk to an Expert
Download Copy Check Circle