Skip to main content
Check out our new courses about Mobile Testing with BrowserStack App Automate on Test University!

Test using passcode-protected devices

In this guide, you’ll learn how to run your Appium tests on passcode-protected devices in BrowserStack.

Overview

Important: Passcode-protected devices are currently available for Android OS 8.0 and above.

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

Since BrowserStack devices are not passcode-protected as a default, you need to add the browserstack.enablePasscode capability in your test script to get access to devices that are password-protected.

Set the capability

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

Sample code snippets

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

Important: The supporting capabilities for the unlock appium command, namely unlockType and unlockKey, are passed automatically to your tests by BrowserStack.
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setCapability("browserstack.enablePasscode", "true");
  
// your test script goes here

// if you want to lock and unlock the device
driver.lockDevice();// to lock the device
driver.unlockDevice();// to unlock the device

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

// your test script goes here
  
// if you want to lock and unlock the device
driver.lockDevice(); // to lock the device
driver.unlockDevice(); // to unlock the device

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

# your test script goes here
  
# if you want to lock and unlock the device
driver.lock(); # to lock the device
driver.unlock();# to unlock the device

desired_caps = {
    "browserstack.enablePasscode" => "true"
}

# your test script goes here
  
# if you want to lock and unlock the device
driver.lock #to lock the device
driver.unlock #to unlock the device

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

// your test script goes here
  
// if you want to lock and unlock the device
driver.Lock();// to lock the device
driver.Unlock();// to unlock the device

After you set this capability in your test script, your tests will run on a passcode-protected 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
Talk to an Expert