Run tests with Biometric authentication

Below you can find information on how to run tests, which include Biometric authentication steps

Prerequisites

  • Existing native application with the Biometric authentication.
  • The app is installed on a device with image injection enabled.
    More details can be found here and in our API reference collection.
  • The tests can operate with system alerts
    For example, using the Appium command.
  • Access key is generated.

Step 1: Add executing of the Biometric authentication API

We have the specific API action for the Biometric authentication in our public API.
The action contains only one boolean parameter, which relates to the authentication result (success or fail)
Below you can find an example for a popular Java API framework.

Rest-assured:

    public void submitBioAuthResult(String serial, boolean isSuccess) {
        JsonObject object = new JsonObject();
        object.addProperty("touchValid", isSuccess);
        RestAssured.given().
                contentType(ContentType.JSON).
                baseUri("https://app.mobitru.com/billing/unit/"+
                      <TEAM_ACCOUNT_NAME>
                      +"/automation/api").
                auth().oauth2(<ACCESS_KEY>).
                when().
                body(object.toString()).
                post("device/{serial}/injection/touch", serial).
                then().
                statusCode(HTTP_NO_CONTENT);
    }

Step 2: Cover the Biometric authentication pop-up

The Mobitru injects a specific pop-up while installing the App.
The pop-up activates when the App is requesting the authentication confirm.
Also, here is an example of the pop-up wait in Java + Appium:

 public void startLoginViaBio() {
        // example of trigger the biometric authentication process
        signInBioButton.click();
        // wait for the pop-up
        new WebDriverWait(driver, Duration.ofSeconds(30), Duration.ofSeconds(1)).
                ignoring(WebDriverException.class).
                until(ExpectedConditions.alertIsPresent());
}

Step 3: Use both actions in a test

In the end, you can cover the full scenario by using both actions one after another.
Below you can find an example for a popular Java Test framework:

    @Test(description = "Check login with biometric auth")
    public void loginValidBio() {
        startLoginViaBio();
        submitBioAuthResult(udid, true);
        //steps afrer success login...
    }

Note:

If you don’t have an Application with Biometric authentication but would like to try the described steps, please use our open-source demo apps for Android and iOS.

Scroll to Top