Best Python code snippet using pytest-mozwebqa_python
14practice.py
Source:14practice.py
1# TODO Selenium 1 åºç¡+è¿é¶â
2"""14-2 selenium IDE å½å¶â
"""3# 13-15Web/14BasicSelenium/test_ide.py4"""14-4 çå¾
â
"""5# æ¾ç¤ºçå¾
ãéå¼çå¾
ãç´æ¥çå¾
6# æ¾ç¤ºçå¾
èªå®ä¹untilå½æ°7# ../14BasicSelenium/test_selenium1.py8"""14-5 å®ä½â
"""9# xpathå®ä½->consoleâ
10# $x("//*[id='s_tab']//a(1)")11# $x("//*[id='s_tab']//a(last())")12# CSSå®ä½->consoleâ
13# $("#s_tab a:nth-child(2)")14"""14-6 è¿é¶â
ï¸"""15# ActionChains16# 1 clickãdouble_clickãcontext_clickâ
17# 13-15Web/14BasicSelenium/test_js.py18# 2 move_to_elementâ
19# 13-15Web/14BasicSelenium/test_selenium1.py20# 3 drag_and_dropâ
21# 13-15Web/14BasicSelenium/test_js.py22from selenium import webdriver23from selenium.webdriver import ActionChains24from time import sleep25driver = webdriver.Chrome()26driver.implicitly_wait(5)27driver.get("http://sahitest.com/demo/dragDropMooTools.htm")28action = ActionChains(driver)29ele1 = driver.find_element_by_id("dragger")30ele2 = driver.find_element_by_css_selector(".item:nth-child(4)")31action.drag_and_drop(ele1, ele2).perform()32sleep(3)33driver.quit()34# 4 key_downãkey_upãKeys.CONTROLâ¦â
35# 13-15Web/14BasicSelenium/test_js.py36# TouchActionsâ
37# 13-15Web/14BasicSelenium/test_selenium1.py38"""14-7 frameâ
"""39# å¤çªå£â
40# 13-15Web/14BasicSelenium/test_selenium1.py41# test_window42# frameâ
43# 13-15Web/15_1-3Notes/test_inputfile_alert.py44"""14-8 å
¼å®¹æ§æµè¯â
"""45# 13-15Web/14BasicSelenium/test_selenium2.py46"""14-9 jsâ
"""47# consoleâ
48"""491.页é¢å¼¹çª50window.alert("hello world")512.页é¢æ§è½52JSON.stringify(performance.timing)533.页é¢æ é¢54document.title554.页é¢å±æ§å¼56document.getElementById("kw").value575.æ»å¨é¡µé¢58document.documentElement.scrollTop596.å»æå±æ§å¼60a = document.getElementById("train_date")61a.removeAttribute("readonly")62a.value = "2000-02-02"63"""64# seleniumèæ¬â
...
test_01.py
Source:test_01.py
1from selenium.webdriver import Chrome2import pytest3a=1014@pytest.mark.skip("Don't want to execute this one")5def test_Selenium():6 path="C://Users//ramadhma//Selenium//chromedriver.exe"7 driver=Chrome(executable_path=path)8 driver.get("https://www.facebook.com/")9@pytest.mark.skipif(a>100, reason="Don't want to execute this one")10def test_Selenium1():11 path="C://Users//ramadhma//Selenium//chromedriver.exe"12 driver=Chrome(executable_path=path)13 driver.get("https://www.facebook.com/")14#test_Selenium()15def test_Selenium2():16 path="C://Users//ramadhma//Selenium//chromedriver.exe"17 driver=Chrome(executable_path=path)18 driver.get("https://www.facebook.com/")19@pytest.mark.Smoke20def test_Selenium():21 path="C://Users//ramadhma//Selenium//chromedriver.exe"22 driver=Chrome(executable_path=path)23 driver.get("https://www.facebook.com/")24@pytest.mark.Sanity25def test_Selenium1():26 path="C://Users//ramadhma//Selenium//chromedriver.exe"27 driver=Chrome(executable_path=path)28 driver.get("https://www.facebook.com/")29#test_Selenium()30@pytest.mark.Smoke31def test_Selenium2():32 path="C://Users//ramadhma//Selenium//chromedriver.exe"33 driver=Chrome(executable_path=path)...
test_Assertion.py
Source:test_Assertion.py
1from selenium.webdriver import Chrome2import pytest3@pytest.mark.skip4def test_Selenium():5 path="C://Users//ramadhma//Selenium//chromedriver.exe"6 driver=Chrome(executable_path=path)7 driver.get("https://www.facebook.com/")8 assert driver.title== "Facebook login"9def test_Selenium1():10 path="C://Users//ramadhma//Selenium//chromedriver.exe"11 driver=Chrome(executable_path=path)12 driver.get("https://www.facebook.com/")...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!