Skip to content

Instantly share code, notes, and snippets.

@SarahElson
SarahElson / testScenarios parallelSignupRun.py
Created September 6, 2022 16:05
Playwright Python Tutorial
import sys
sys.path.append(sys.path[0] + "/..")
from testScripts.parallelSignup import Register
from playwright.sync_api import sync_playwright
with sync_playwright() as playwright:
try:
Project Directory
|-----------elementSelectors
| |----------------loginAndBuySelectors.py
| |----------------registrationPageSelectors.py
|
|------------testCapabilities
| |-----------------testCaps.py
|
|-------------testScenarios
| |-----------------.env
@SarahElson
SarahElson / playwright_python_test_structure.py
Created September 6, 2022 16:12
Playwright Python Tutorial: Getting Started With Python End To End Testing
Project Directory
|-----------elementSelectors
| |----------------loginAndBuySelectors.py
| |----------------registrationPageSelectors.py
|
|------------testCapabilities
| |-----------------testCaps.py
|
|-------------testScenarios
| |-----------------.env
@SarahElson
SarahElson / testCaps.py
Created September 6, 2022 16:16
Playwright Python Tutorial: Getting Started With Python End To End Testing
import json
import os
import urllib.parse
import subprocess
from dotenv import load_dotenv
load_dotenv('.env')
username = os.getenv("my_username")
gridAcessKey = os.getenv("access_key")
@SarahElson
SarahElson / registrationPageSelectors.py
Created September 6, 2022 16:21
Playwright Python Tutorial: Getting Started With Python End To End Testing
webElements = {
'webpage': "https://ecommerce-playground.lambdatest.io/index.php?route=account/register",
'First_Name': 'input[placeholder="First Name"]',
'Last_Name': 'input[placeholder="Last Name"]',
'E-Mail': 'input[placeholder="E-Mail"]',
'Telephone': 'input[placeholder="Telephone"]',
'Password': 'input[placeholder="Password"]',
'Confirm_Password': 'input[placeholder="Password Confirm"]',
'Subscribe': 'label:has-text("No")',
'Privacy_Policy': 'label:has-text("I have read and agree to the Privacy Policy")',
@SarahElson
SarahElson / singleSignupScript.py
Created September 6, 2022 16:22
Playwright Python Tutorial: Getting Started With Python End To End Testing
from playwright.sync_api import sync_playwright
import sys
sys.path.append(sys.path[0] + "/..")
from elementSelectors.registrationPageSelectors import elementSelector
from testCapabilities.testCaps import testCapabilities
select = elementSelector()
@SarahElson
SarahElson / singleSignupRun.py
Created September 6, 2022 16:23
Playwright Python Tutorial: Getting Started With Python End To End Testing
import sys
sys.path.append(sys.path[0] + "/..")
from testScripts.singleSignupScript import Register
from playwright.sync_api import sync_playwright
with sync_playwright() as playwright:
try:
@SarahElson
SarahElson / testScripts parallelLoginBuyScript.py
Created September 6, 2022 16:24
Playwright Python Tutorial
from playwright.sync_api import sync_playwright
import sys
sys.path.append(sys.path[0] + "/..")
from elementSelectors.loginAndBuySelectors import elementSelector
from testCapabilities.testCaps import testCapabilities
select = elementSelector()
@SarahElson
SarahElson / testScenarios parallelLoginBuyRun.py
Created September 6, 2022 16:27
Playwright Python Tutorial
import sys
sys.path.append(sys.path[0] + "/..")
from testScripts.parallelLoginBuyScript import LoginAndBuy
from playwright.sync_api import sync_playwright
with sync_playwright() as playwright:
try:
playwright = LoginAndBuy(playwright)
@SarahElson
SarahElson / loginAndBuySelectors.py
Created September 6, 2022 16:39
Playwright Python Tutorial: Getting Started With Python End To End Testing
webElements = {
'webpage': "https://ecommerce-playground.lambdatest.io/index.php?route=account/login",
'E-Mail': 'input[placeholder="E-Mail Address"]',
'Password': 'input[placeholder="Password"]',
'Login': 'input:has-text("Login")',
'Search': 'input[name="search"] >> nth = 0',
'searchbutton': 'div[class="search-button"]:has-text("Search")',
'product': 'h4[class="title"]:has-text("Nikon D300") >> nth = 0',
'addcart': 'div[id="entry_216842"]:has-text("Add to Cart")',
'checkoutmodal': 'div[role="alert"]:has-text("Checkout")',