How to use FindByCSS method in websmith

Best Python code snippet using websmith_python

test_items.py

Source:test_items.py Github

copy

Full Screen

1import time2from selenium.webdriver.common.by import By3from selenium.webdriver.support.ui import WebDriverWait4from selenium.webdriver.support import expected_conditions as EC5from selenium.common.exceptions import TimeoutException6link = "http://selenium1py.pythonanywhere.com/catalogue/coders-at-work_207/"7def findByCss(browser, selector):8 return WebDriverWait(browser, 5).until(9 EC.presence_of_element_located((By.CSS_SELECTOR, selector))10 )11def if_element_exist(browser, selector):12 try:13 findByCss(browser, selector)14 except TimeoutException:15 return False16 return True17def test_busket_button_exist(browser):18 browser.get(link)19 assert if_element_exist(browser, '.btn-add-to-basket'), 'An element has no exist'...

Full Screen

Full Screen

locatorsbycssselector.py

Source:locatorsbycssselector.py Github

copy

Full Screen

1import time2from selenium import webdriver3from webdriver_manager.chrome import ChromeDriverManager4class DemoFindElementByCSS():5 def locate_by_id(self):6 driver = webdriver.Chrome(executable_path = ChromeDriverManager().install())7 driver.get("https://secure.yatra.com/social/common/yatra/signin.htm")8 driver.find_element_by_css_selector('#login-input').send_keys('test@test.com')9 time.sleep(5)10findbyCSS = DemoFindElementByCSS()...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run websmith automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful