Skip to main content
Start running your tests on the latest iOS minor versions on BrowserStack App Automate. Check out our documentation!

Test using passcode-protected devices

Important: This feature for iOS devices is currently in Beta and may involve changes based on feedback.

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 browserstack.enablePasscode 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

The following table lists information regarding the browserstack.enablePasscode capability.

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

Use the following code snippet that sets the browserstack.enablePasscode capability to true in your test scripts.

DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setCapability("browserstack.enablePasscode", "true");


var capabilities = {
    "browserstack.enablePasscode" : "true"
}

desired_cap = {
	"browserstack.enablePasscode" : "true"
}

desired_caps = {
    "browserstack.enablePasscode" => "true"
}
DesiredCapabilities capability = new DesiredCapabilities();
desiredCapabilities.SetCapability("browserstack.enablePasscode", "true");

After you set this capability in your test script, your tests will run on a passcode-protected device.

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.

Important: 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.unlockDevice();// to unlock the device

// your test script goes here

driver.unlockDevice(); // to unlock the device

# your test script goes here

driver.unlock();# to unlock the device

# your test script goes here
  
driver.unlock #to unlock the device

// your test script goes here
driver.Unlock();// to unlock the device

For iOS devices, the unlock pin is 123456.

In your test script, write an automation code that taps and sets the device passcode to 123456.

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
Talk to an Expert