Created
September 13, 2024 12:37
-
-
Save SarahElson/a4a0b8c5f654b245b33659c93c287dbc to your computer and use it in GitHub Desktop.
How to Test Biometric Authentication With Appium
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AndroidDriverManager { | |
private AndroidDriver androidDriver; | |
public void createAndroidDriverInCloud() { | |
final String ltUserName = System.getenv("LT_USERNAME"); | |
final String ltAccessKey = System.getenv("LT_ACCESS_KEY"); | |
final String gridUrl = "@mobile-hub.lambdatest.com/wd/hub"; | |
try { | |
this.androidDriver = new AndroidDriver(new URL(format("https://{0}:{1}{2}", ltUserName, ltAccessKey, gridUrl)), setCapabilities()); | |
} catch (MalformedURLException e) { | |
throw new Error("Error while setting up Android Driver in cloud", e); | |
} | |
setupDriverTimeouts(); | |
} | |
private HashMap<String, Object> ltOptions() { | |
final var ltOptions = new HashMap<String, Object>(); | |
ltOptions.put("platformName", "ANDROID"); | |
ltOptions.put("deviceName", "Galaxy S23"); | |
ltOptions.put("platformVersion", "13"); | |
ltOptions.put("app", "lt://APP1016043281711707979395880"); | |
ltOptions.put("w3c", true); | |
ltOptions.put("isRealMobile", true); | |
ltOptions.put("autoGrantPermissions", true); | |
ltOptions.put("enableBiometricsAuthentication", true); | |
ltOptions.put("build", "Appium biometric test suite"); | |
ltOptions.put("name", "Test fingerprint authentication on login"); | |
ltOptions.put("plugin", "java-testNG"); | |
ltOptions.put("visual", true); | |
ltOptions.put("console", true); | |
ltOptions.put("devicelog", true); | |
return ltOptions; | |
} | |
private DesiredCapabilities setCapabilities() { | |
final DesiredCapabilities capabilities = new DesiredCapabilities(); | |
capabilities.setCapability("lt:options", ltOptions()); | |
return capabilities; | |
} | |
public AndroidDriver getAndroidDriver() { | |
return this.androidDriver; | |
} | |
private void setupDriverTimeouts() { | |
getAndroidDriver().manage() | |
.timeouts() | |
.implicitlyWait(Duration.ofSeconds(5)); | |
} | |
public void quitDriver() { | |
getAndroidDriver().quit(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment