Test biometric authentication on BrowserStack mobile devices
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 :
- How to test Biometric authentication in an App Automate session
- Frequently Asked Questions (FAQs)
- 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 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
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\"
}}”)
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. 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 :
-
BiometricPrompt
API. For more details, please check BiometricPrompt Google documentation. -
BiometricManager
API. For more details, please check BiometricManager Google documentation. -
KeyguardManager
API. For more details, please check KeyguardManager Google documentation. -
FingerprintManager
API. For more details, please check FingerprintManager Google documentation.
On iOS, currently we support the following Biometric APIs in iOS SDK :
-
canEvaluatePolicy
&evaluatePolicy
APIs from theLAContext
class in the Apple’s iOS Biometric SDK. For more details, please check LAContext Apple documentation.
- Currently, we don’t support apps using iOS Keychain APIs with Biometric access control. For more details, check Apple documentation on Keychain access with Biometric authentication.
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.
- Biometric feature is supported only on Android 6.0 & above
- Apps using code obfuscation tools such as Proguard are not supported
- 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 betrue
.
Related topics
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
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!