Last active
August 31, 2022 16:31
-
-
Save SarahElson/0cc18159a672bf93e5cdf2cca97768fc to your computer and use it in GitHub Desktop.
Selenium Python Tutorial: A Python Automation Testing Guide with examples
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
#Implementation of Selenium WebDriver with Python using PyTest | |
import pytest | |
from selenium import webdriver | |
import sys | |
from selenium.webdriver.chrome.options import Options | |
from selenium.webdriver.common.keys import Keys | |
from time import sleep | |
saf_capabilities = { | |
"build" : "Porting test to LambdaTest Selenium Grid (Safari)", | |
"name" : "Porting test to LambdaTest Selenium Grid (Safari)", | |
"platform" : "MacOS Big sur", | |
"browserName" : "Safari", | |
"version" : "14.0" | |
} | |
def test_lambdatest_todo_app(): | |
# ff_driver = webdriver.Firefox() | |
# Profile Link - https://accounts.lambdatest.com/detail/profile | |
user_name = "user_name" | |
app_key = "access_key" | |
# chrome_driver = webdriver.Chrome() | |
remote_url = "https://" + user_name + ":" + app_key + "@hub.lambdatest.com/wd/hub" | |
ff_driver = webdriver.Remote(command_executor = remote_url, desired_capabilities = saf_capabilities) | |
ff_driver.get('https://lambdatest.github.io/sample-todo-app/') | |
ff_driver.maximize_window() | |
ff_driver.find_element_by_name("li1").click() | |
ff_driver.find_element_by_name("li2").click() | |
title = "Sample page - lambdatest.com" | |
assert title == ff_driver.title | |
sample_text = "Happy Testing at LambdaTest" | |
email_text_field = ff_driver.find_element_by_id("sampletodotext") | |
email_text_field.send_keys(sample_text) | |
sleep(5) | |
ff_driver.find_element_by_id("addbutton").click() | |
sleep(5) | |
output_str = ff_driver.find_element_by_name("li6").text | |
sys.stderr.write(output_str) | |
sleep(2) | |
ff_driver.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment