Create a biometric authentication script

Learn how to create a biometric authentication script so you can test your app’s authentication capabilities.

Before you start

You’ll need to add our biometric authentication library to your iOS and Android apps:

Learn about the benefits of our biometrics authentication library.

Script parameters

After you send a biometric authentication request, end-users can choose to authenticate themselves (pass) or reject your request (fail). Use these scripts to test how your app responds to each choice:

driver.execute('mobile:biometrics-authenticate', {result: 'passed'})

Simulate the end-user authenticating themselves.

driver.execute('mobile:biometrics-authenticate', {result: 'failed'})

Simulate the end-user rejecting your request.

Example
def test_biometric_authentication():
    try:
        # Look for the XPath containing the words "Log In" and select the element.
        wait = WebDriverWait(driver, 10)
        log_in_element = wait.until(EC.presence_of_element_located((By.XPATH, '//XCUIElementTypeStaticText[@id="Log In"]')))
        log_in_element.click()

        # Wait for 20 seconds for the biometric authentication screen to load.
        driver.implicitly_wait(20)

        # Simulate the end-user authenticating themselves.
        driver.execute('mobile:biometrics-authenticate', {'result': 'passed'})

    # Catch any errors that occur.
    except Exception as e:

        # Log the error in the console.
        print(e)

        # Throw the error to stop the test.
        raise e