Skip to content

Instantly share code, notes, and snippets.

@SarahElson
SarahElson / AndroidDriverManager.java
Created September 13, 2024 12:49
How to Test Biometric Authentication With Appium
public void createAndroidDriver() {
try {
this.androidDriver = new AndroidDriver(new URL("http://127.0.0.1:4723/"), uiAutomator2Options());
} catch (final MalformedURLException e) {
throw new Error("Error while setting up Android Driver", e);
}
setupDriverTimeouts();
}
@SarahElson
SarahElson / testng.xml
Created September 13, 2024 12:43
How to Test Biometric Authentication With Appium
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Biometric authentication tests for Android using appium">
<test name="Instrumentation App Biometric Authentication Tests" >
<classes>
<class name="io.github.mfaisalkhatri.tests.BiometricAuthTests">
<methods>
<include name="testSuccessfulBiometricAuthenticationUsingLambdaTest"/>
<include name="testFailedBiometricAuthenticationUsingLambdaTest"/>
</methods>
@SarahElson
SarahElson / Homepage.java
Last active September 13, 2024 14:49
How to Test Biometric Authentication With Appium
public class HomePage {
private final AndroidDriver androidDriver;
public HomePage(final AndroidDriver androidDriver) {
this.androidDriver = androidDriver;
}
private WebElement biometricBtn() {
return this.androidDriver.findElement(AppiumBy.id("com.poc.sample:id/biometric"));
@SarahElson
SarahElson / BiometricAuthTests.java
Last active September 13, 2024 14:48
How to Test Biometric Authentication With Appium
public class BiometricAuthTests extends BaseTest {
@Test
public void testSuccessfulBiometricAuthenticationUsingLambdaTest() {
final HomePage homePage = new HomePage(this.androidDriverManager.getAndroidDriver());
homePage.performSuccessBioMetricAuthenticationOnRealDevice();
assertEquals(homePage.getMessageText(), "Success");
}
@SarahElson
SarahElson / Base Test.java
Last active September 13, 2024 14:46
How to Test Biometric Authentication With Appium
public class BaseTest {
protected AndroidDriverManager androidDriverManager;
@BeforeClass(alwaysRun = true)
public void setup(final String deviceType) {
this.androidDriverManager = new AndroidDriverManager();
this.androidDriverManager.createAndroidDriverInCloud();
}
@SarahElson
SarahElson / Configuration (AndroidDriverManager.java)
Created September 13, 2024 12:37
How to Test Biometric Authentication With Appium
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";
@SarahElson
SarahElson / testng-pagination-tests.xml
Created September 13, 2024 11:19
Selenium Pagination Tutorial: How to Handle Page Navigation
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Automating Pagination with Selenium">
<test name="Pagination tests - LambdaTest e-commerce website">
<classes>
<class name="io.github.mfaisalkhatri.paginationdemo.tests.SeleniumPaginationTests">
<methods>
<include name="testProductDetailsOnAllPage"/>
<include name="testFilterRecordsOnPage"/>
<include name="testSearchForProduct"/>
@SarahElson
SarahElson / BaseTest.java
Created August 13, 2024 14:38
ExpectedConditions In Selenium: Types And Examples
public class BaseTest {
protected RemoteWebDriver driver;
@BeforeClass
public void setup() {
String USERNAME = System.getenv("LT_USERNAME") == null ? "LT_USERNAME" : System.getenv("LT_USERNAME");
String ACCESS_KEY = System.getenv("LT_ACCESS_KEY") == null ? "LT_ACCESS_KEY" : System.getenv("LT_ACCESS_KEY");
String GRID_URL = "@hub.lambdatest.com/wd/hub";
@SarahElson
SarahElson / pom.xml
Created August 13, 2024 14:37
ExpectedConditions In Selenium: Types And Examples
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>io.github.mfaisalkhatri</groupId>
<artifactId>selenium-lambdatest-demo</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
@SarahElson
SarahElson / tests_data_integrity.py
Created August 9, 2024 10:33
Python Assert Keyword: A Complete Guide
from selenium import webdriver
from base import SampleTest
import unittest
class DataIntegrityTest(SampleTest):
def test_data_integration(self):
driver = self.driver
driver.get("https://ecommerce-playground.lambdatest.io/index.php?route=common/home")