Skip to content

Instantly share code, notes, and snippets.

@SarahElson
SarahElson / pom.xml
Created June 6, 2024 06:53
How To Get Element by Tag Name in Selenium
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>GetElementByTagNameSelenium</groupId>
<artifactId>GetElementByTagNameSelenium</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>GetElementByTagNameSelenium</name>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
@SarahElson
SarahElson / pages_smartwait.py
Created June 4, 2024 20:02
How to Wait in Python: Python Wait Tutorial With Examples
from selenium.webdriver.common.by import By
class SmartWait():
def __init__(self, driver):
self.driver = driver
self.driver.get("https://ecommerce-playground.lambdatest.io/")
self.blog_link = driver.find_element(By.LINK_TEXT, "Blog")
@SarahElson
SarahElson / pages_fluent_wait.py
Created June 4, 2024 19:58
How to Wait in Python: Python Wait Tutorial With Examples
from selenium.webdriver.common.by import By
class FluentWait:
def __init__(self, driver):
self.driver = driver
self.driver.get("https://ecommerce-playground.lambdatest.io/")
@SarahElson
SarahElson / pages_explicit_wait.py
Created June 4, 2024 19:54
How to Wait in Python: Python Wait Tutorial With Examples
from selenium.webdriver.common.by import By
class ExplicitWait:
def __init__(self, driver):
self.driver = driver
self.driver.get("https://ecommerce-playground.lambdatest.io/")
@SarahElson
SarahElson / pages_implicit_wait.py
Created June 4, 2024 19:45
How to Wait in Python: Python Wait Tutorial With Examples
from selenium.webdriver.common.by import By
class ImplicitWait:
def __init__(self, driver):
self.driver = driver
self.driver.get("https://ecommerce-playground.lambdatest.io/")
@SarahElson
SarahElson / pages_sleep_wait.py
Created June 4, 2024 19:36
How to Wait in Python: Python Wait Tutorial With Examples
from selenium.webdriver.common.by import By
class SleepWait:
def __init__(self, driver):
self.driver = driver
self.driver.get("https://ecommerce-playground.lambdatest.io/")
@SarahElson
SarahElson / conftest.py
Created June 4, 2024 19:26
How to Wait in Python: Python Wait Tutorial With Examples
from os import environ
import pytest
from selenium import webdriver
from smartwait_option import option_smartwait
@pytest.fixture(scope="function")
def driver(request):
@SarahElson
SarahElson / test.py
Created May 31, 2024 15:11
What Is Parallel Testing And Why Is It Important?
# Import the functions for retrieving the title and its length from parallel_testing file
from parallel_testing import get_title, get_title_length
# Test function to verify the web page title retrieved from browser
def test_title():
title = get_title()
assert title == "Your Store", "Test not passed for title"
@SarahElson
SarahElson / parallel_testing.py
Created May 31, 2024 15:09
What Is Parallel Testing And Why Is It Important?
# Import the required packages
from selenium import webdriver
# Function to retrieve the title of the web page
def get_title():
# Configure Chrome WebDriver options
options = webdriver.ChromeOptions()
options.add_experimental_option('excludeSwitches', ['enable-logging'])
@SarahElson
SarahElson / test.js
Created May 30, 2024 07:15
Selenium sendKeys(): A Complete Guide
const { setupDriver } = require("./web-driver");
async function performSearch() {
const driver = await setupDriver();
try {
// Navigate to Google's homepage
await driver.get("<https://www.google.com/>");
// Find the search input element and send the search query