Automating biometric authentication on iOS using BrowserStack
Introduction:-
Today, almost all mobile devices support biometric authentication, such as Touch ID/Fingerprint Sensors and Face ID. Using the Browser Stack Android/iOS testing platform, developers can test their mobile applications using biometric authentication. In Automating biometric authentication on iOS using BrowserStack users can be authenticated using biometrics.
Note – This feature is currently not available for Android devices.
My application uses biometric authentication when it relaunches (relaunching means that the user is logged in and the app is closed from the background). Let’s look at a practical example.
How to check biometric authentication:
You can check Biometric authentication in an App Automate session by following these steps:
- A browser Stack Appium session can be enabled with Biometrics by using the following Browserstack Appium capability: BrowserStack.enable biometric:”true”
- As shown below, this capability ensures that your app passes through Sensor Instrumentation.
def before_scenario(context,scenario):
if context.config.userdata["executionMode"]=="Browserstack":
context.driver =webdriver.Remote(
command_executor='https://'+context.config.userdata["userName"]+':'+context.config.u
serdata["accessKey"]+'@hub-cloud.browserstack.com/wd/hub',
desired_capabilities={
"platformName": "iOS",
"build": context.config.userdata["browserstack_build"],
"device": context.config.userdata["browserstack_device"],
"os_version": context.config.userdata["device_os_version"],
"app":context.config.userdata["browserstack_appUrl"],
"nativeWebTap":True,
"browserstack.enableBiometric": True #desired Capability
}
)
elif context.config.userdata["executionMode"]=="Emulator":
context.driver = webdriver.Remote(
.
.
.
By using the ‘before scenario’ context in the ‘environment.py’ file, this Python code creates the desired capability. As a result of using this capability, we get the following screen when it is executed.
How to interact with the Biometric authentication dialog:
Using the custom executor, you can manipulate the Automating biometric authentication on iOS using BrowserStack dialog box.
Following are the complete scenario and required steps with the page file code.
Scenario: User Login by biometric after app relaunch
Given User is on "Welcome" page
And User does Login with "Username" and "Password"
When User creates security pin for "Username"
# creates security step depends on application
And User closes app and relaunch the app
Then User clicks "Pass" on biometric alert screen
#Then User clicks "Fail" on biometric alert screen
Step definition file –
@then('I click "{option}" on biometric alert screen')
def step_impl(context,option):
context.signIn.clickon_pass(option)
Page file –
def clickon_pass(self,option):
self.driver.find_element_by_accessibility_id(option).click()
sleep(5)
Note: – There are two options here ‘Pass’ or ‘Fail’
The application opens when the user clicks ‘Pass’ on the authentication alert screen.
If you click “Fail” on the authentication alert screen, the application will request that you re-login with your forgotten pin or security pin instead of biometric information.
This feature supports native apps & apps built with cross-platform frameworks such as React Native, Flutter, etc. The BrowserStack Biometric feature supports Biometric APIs. only if the app uses one of the supported Biometric APIs. A biometric API can be used with the approval of the app development team on Android and iOS.
Conclusion:
The BrowserStack platform with Appium capabilities allows developers and testers to test mobile applications with Biometric Authentication.
Gajashree is working as SDET from last 2 years with us. Having experience in Web, Mobile, API Manual and Automation testing. Having hands-on experience in selenium, BDD with java, python & tools- Appium, BrowserStack as well as web designing.