Skip to content

Instantly share code, notes, and snippets.

@SarahElson
Created September 13, 2024 12:54
Show Gist options
  • Save SarahElson/a0dd9f6adc27cbf500dc3c193aafe6d7 to your computer and use it in GitHub Desktop.
Save SarahElson/a0dd9f6adc27cbf500dc3c193aafe6d7 to your computer and use it in GitHub Desktop.
How to Test Biometric Authentication With Appium
public class LoginPage {
private final AndroidDriver androidDriver;
private final WebDriverWait wait;
public LoginPage(final AndroidDriver androidDriver) {
this.androidDriver = androidDriver;
this.wait = new WebDriverWait(androidDriver, Duration.ofSeconds(10));
}
private WebElement fingerPrintBtn() {
return this.androidDriver.findElement(AppiumBy.accessibilityId("button-biometric"));
}
private WebElement cancelBtnInAuthenticationView() {
return this.wait.until(ExpectedConditions.visibilityOfElementLocated(AppiumBy.accessibilityId("Tap to cancel authentication")));
}
public void performBiometricLogin(final int fingerPrintId) {
fingerPrintBtn().click();
cancelBtnInAuthenticationView().isDisplayed();
this.androidDriver.fingerPrint(fingerPrintId);
}
public String getSuccessMessageTitle() {
return this.wait.until(ExpectedConditions.visibilityOfElementLocated(AppiumBy.id("android:id/alertTitle"))).getText();
}
public String getSuccessMessageText () {
return this.androidDriver.findElement(AppiumBy.id("android:id/message")).getText();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment