Skip to content

Instantly share code, notes, and snippets.

@SarahElson
SarahElson / test_wait_state_navigation.py
Created May 9, 2024 12:13
How to Use Playwright Wait For Navigation Methods
from playwright.sync_api import expect
from fixtures.wait_fixture import page, browser, set_test_status
# page = fixtures.wait_fixture.page
def test_wait_state_navigation(page, set_test_status):
page.goto("https://ecommerce-playground.lambdatest.io/")
# wait for load state wait until naviagtion is complete
@SarahElson
SarahElson / test_wait_function_navigation.py
Created May 9, 2024 12:10
How to Use Playwright Wait For Navigation Methods
from playwright.sync_api import expect
from fixtures.wait_fixture import page, browser, set_test_status
def test_wait_function_navigation(page, set_test_status):
page.goto("https://ecommerce-playground.lambdatest.io/")
page.get_by_role("link", name="Jolio Balia", exact=True).nth(1).click()
page.evaluate("() => document.title")
# waits for function to return truthy value
page.wait_for_function("title = 'Jolio Balia'; () => document.title === title")
@SarahElson
SarahElson / test_wait_event_navigation.py
Created May 9, 2024 12:08
How to Use Playwright Wait For Navigation Methods
from playwright.sync_api import expect
from fixtures.wait_fixture import page, browser, set_test_status
def test_wait_event_navigation(page, set_test_status):
page.goto("https://ecommerce-playground.lambdatest.io/")
page.get_by_role("button", name="Shop by Category").click()
page.get_by_role("link", name="Cameras", exact=True).click()
# waits for event load to be completed
page.wait_for_event("domcontentloaded")
@SarahElson
SarahElson / wait_fixture.py
Created May 9, 2024 12:06
How to Use Playwright Wait For Navigation Methods
import json
import os
import urllib
import subprocess
import pytest
from playwright.sync_api import sync_playwright
from dotenv import load_dotenv
@SarahElson
SarahElson / testng.xml
Created May 8, 2024 07:01
Handling Alerts and Popups in Appium
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Lambda tests Mobile automation test suite">
<test name="Proverbial app - iOS Mobile Automation tests for popup">
<parameter name="buildName" value="IOS Build"/>
<parameter name="testName" value="Find My App tests"/>
<parameter name="app" value="lt://APP10160531401673434634013700"/>
<parameter name="platformName" value="IOS"/>
<parameter name="version" value="13"/>
<parameter name="device" value="iPhone 8 Plus"/>
@SarahElson
SarahElson / pom.xml
Created May 8, 2024 06:54
Handling Alerts and Popups in Appium
<?xml version="1.0" encoding="UTF-8"?>
<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>react-native-app-mobile-testing</artifactId>
<version>1.0-SNAPSHOT</version>
@SarahElson
SarahElson / test_form_demo.py
Created May 2, 2024 10:22
How to Use pytest Skip Test And XFail in Selenium
#It will be skipped when adding an addopts option in pytest.ini file -k "not 06"
def test_06(browser):
browser.get("https://www.lambdatest.com/selenium-playground/simple-form-demo")
assert browser.title == "Selenium Grid Online | Run Selenium Test On Cloud"
@SarahElson
SarahElson / pytest.ini
Created May 2, 2024 10:21
How to Use pytest Skip Test And XFail in Selenium
[pytest]
addopts = -k "not 06"
@SarahElson
SarahElson / HomePage.java
Created April 22, 2024 07:41
How to Handle Shadow Root in Selenium Java
package pages.htmlelements;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.SearchContext;
import org.openqa.selenium.WebElement;
import static setup.DriverManager.getDriver;
public class HomePage {
@SarahElson
SarahElson / ShadowRootTests.java
Created April 22, 2024 07:40
How to Handle Shadow Root in Selenium Java
public class ShadowRootTests extends BaseTest {
@BeforeClass
public void navigateToWebsite() {
getDriver().get("https://www.htmlelements.com/demos/menu/shadow-dom/index.htm");
}
@Test
public void testFileMenuShadowRootElement() {
final HomePage homePage = new HomePage();