Skip to main content
Transform your testing process with: Real Device Features, Company-wide Licences, & App Percy
No Result Found

Test biometric authentication on BrowserStack mobile devices

Important: 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.

The majority of mobile devices today support Biometric hardware sensors to authenticate device owner’s identity. BrowserStack enables you to test Biometric Authentication such as Touch ID/Fingerprint Sensor, Face ID, etc on a BrowserStack mobile device.

In this guide, you will learn about :

  1. How to test Biometric authentication in an App Automate session
  2. Frequently Asked Questions (FAQs)
Note: Effective 30th December 2024, we have enhanced the functioning of the biometric authentication feature to support testing scenarios around failing authentication multiple times. To test such scenarios, you must:
  • Contact our Support team and request an upgrade to the current Biometric Authentication flow.
  • Upload your apps to BrowserStack App Automate again.

1. How to test Biometric authentication in an App Automate session

To test Biometric Authentication feature in your mobile apps, follow the below outlined steps :

1.1 Enable Biometric Authentication in the Appium Session

Use BrowserStack’s Appium capability to enable Biometric in a BrowserStack Appium session.

This ensures your app undergoes Sensor Instrumentation which is a process using which BrowserStack supports app’s interaction with different mobile sensors such as Biometric.

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

Capability Description Expected values
enableBiometric Enable Biometric Authentication true/false
browserstack.yml
Copy icon Copy

BrowserStack SDK is a plug-n-play solution that takes care of all the integration steps for you. Using the BrowserStack SDK is the recommended integration method for your project. To know more, visit the SDK core concepts page.

Use the following code snippet to enable Biometric Authentication:

Capability Description Expected values
enableBiometric Enable Biometric Authentication true/false
DesiredCapabilities capabilities = new DesiredCapabilities();
HashMap<String, Object> browserstackOptions = new HashMap<String, Object>();
browserstackOptions.put("enableBiometric", "true");
var capabilities = {
  	'bstack:options' : {
  		"enableBiometric" : "true",
  	},
}
desired_cap = {
  	'bstack:options' : {
  		"enableBiometric" : "true",
  	},
}
capabilities = {
    'bstack:options' => {
        "enableBiometric" => "true",
    },
}
AppiumOptions capabilities = new AppiumOptions();
Dictionary<string, object> browserstackOptions = new Dictionary<string, object>();
browserstackOptions.Add("enableBiometric", "true");
Capability Description Value
browserstack.enableBiometric Enable Biometric Authentication true/false
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setCapability("browserstack.enableBiometric", "true");
var capabilities = {
    "browserstack.enableBiometric" : "true"
}
desired_cap = {
	"browserstack.enableBiometric" : "true"
}
desired_caps = {
    "browserstack.enableBiometric" => "true"
}
DesiredCapabilities capability = new DesiredCapabilities();
desiredCapabilities.SetCapability("browserstack.enableBiometric", "true");

1.2 Use BrowserStack’s custom executor to interact with Biometric authentication dialog

Biometric Auth Dialog

When your sensor instrumented app shows the Biometric Authentication alert, you can use the Browserstack custom executor to interact with the alert. The custom executor contains an action biometric and an argument biometricMatch through which you can send values Pass, Fail, or Cancel to the authentication alert. For example:

driver.executeScript("browserstack_executor: {\"action\":\"biometric\", \"arguments\": {
    \"biometricMatch\" : \"pass\"
}})
await driver.execute("browserstack_executor: {\"action\":\"biometric\", \"arguments\": {
  \"biometricMatch\" : \"pass\"
}}”)
driver.execute_script("browserstack_executor: {\"action\":\"biometric\", \"arguments\": {
    \"biometricMatch\" : \"pass\"
}}”)
@driver.execute_script("browserstack_executor: {\"action\":\"biometric\", \"arguments\": {
    \"biometricMatch\" : \"pass\"
}}”)
driver.executeScript("browserstack_executor: {\"action\":\"biometric\", \"arguments\": {
    \"biometricMatch\" : \"pass\"
}})
Note: On iOS, if the Biometric Authentication prompt does not show up and the test passes automatically, then contact our Support team.

1.3 Test authentication scenarios

You can use the custom executor to select Pass, Fail, or Cancel on your device and test various authentication success or failure scenarios. BrowserStack App Automate attempts to closely mimic the biometric authentication behaviour on real devices. Based on your platform, refer to this table to understand device behaviour:

Scenario Action Behaviour
Pass biometric authentication In the custom executor, send the biometricMatch value as pass. The biometric authentication is passed and the app behaves as designed.
Fail biometric authentication On real Android devices, biometric authentication fails after five incorrect/unsuccessful attempts. To fail biometric authentication on BrowserStack Android devices, send the biometricMatch value as fail for five times. The biometric authentication is considered failed and
- if you do not have a fallback defined, you should see the error code, ERROR_LOCKOUT. Also, you will not experience the 30-sec wait period like on real Android devices.

- if you have a fallback defined in your app, BrowserStack App Automate displays another pop-up to simulate device passcode. This pop-up can be closed by sending either the pass or cancel value through the custom executor.Device Passcode Pass or Fail

Note: On real devices running Android above version 15, the device locks itself after five failures. However, in such cases, on BrowserStack devices, biometric authentication will directly get cancelled with the ERROR_LOCKOUT error code.

Similarly, for devices running Android versions lower than 10, since Android does not offer a default fallback mechanism, the device passcode screen is not displayed.
Cancel biometric authentication In the custom executor, send the biometricMatch value as cancel. When you send cancel to BrowserStack devices, biometric authentication is cancelled and the BIOMETRIC_ERROR_USER_CANCELED error code is sent.
If you have defined custom logic for cancellation after a certain number of failures, biometric authentication is cancelled and the BIOMETRIC_ERROR_CANCELED error code is sent.
Scenario Action Behaviour
Pass biometric authentication In the custom executor, send the biometricMatch value as pass. The biometric authentication is passed and the app behaves as designed.
Fail biometric authentication In the custom executor, send the biometricMatch value as fail. The biometric authentication is failed and the app behaves as designed.
Cancel biometric authentication In the custom executor, send the biometricMatch value as cancel. The biometric authentication is cancelled and the app behaves as designed.

Frequently Asked Questions (FAQs)

1. How does Biometric Authentication work on BrowserStack mobile devices?

BrowserStack supports an app’s interaction with different mobile sensors such as Biometric using Sensor Instrumentation. Sensor Instrumentation is the process in which, if Biometric is enabled for the session, we inject BrowserStack’s Biometric code module into the app which mocks or overrides Biometric APIs used by the app.

2. What Biometric APIs are supported by BrowserStack Biometric feature?

Please note that Biometric feature will work only if the app uses any of the following supported Biometric APIs. To get more details about the Biometric APIs your app uses please check with your app development team.

On Android, currently we support the following Biometric APIs in Android SDK :

On iOS, currently we support the following Biometric APIs in iOS SDK :

  • canEvaluatePolicy & evaluatePolicy APIs from the LAContext class in the Apple’s iOS Biometric SDK. For more details, please check LAContext Apple documentation.
Note: On iOS :

3. Do we need to register Biometric on the mobile device or make any changes in the app code?

NO. You do not need to register any Biometric on the mobile device or make any changes in the app code.

4. What kind of apps are supported?

We support native apps & apps built with cross platform frameworks such as React Native, Flutter, etc.

Note: On Android :
  • Biometric feature is supported only on Android 6.0 & above
  • Apps using code obfuscation tools such as Proguard are not supported
On iOS :
  • Biometric feature is supported only on iOS 13 & above devices.
  • iOS apps signed with Enterprise certificates are not supported. Biometric feature needs browserstack.resignApp to be true.

Check this page for a list of various JavaScript Executors that BrowserStack offers.

Need some help?

If you have any queries, please 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