Best Python code snippet using lettuce_webdriver_python
base_page.py
Source:base_page.py
...55 print('Try to find icon user...', end='')56 assert self.is_element_present(*BasePageLocators.USER_ICON),\57 "User icon is not presented, probably unauthorised user"58 print('Ok, icon found. Authorised user')59 def url_should_contain(self, strparam:str):60 """пÑовеÑка, ÑÑо browser.current_url ÑодеÑÐ¶Ð¸Ñ Ð² Ñебе <strparam>"""61 print(f'Verify that current URL contain "{strparam}"...', end='')62 assert strparam in self.browser.current_url, \63 f'Opened wrong page from link:{self.url}. Page link not contain "{strparam}"'64 print('Ok')65 def go_to_login_page(self):66 login_link = self.should_be_login_link()67 print(f'Running method login_link.click from page {self.url}')68 login_link.click()69 assert '/login' in self.browser.current_url, f'Opened not login page from link:{self.url}.'70 def go_to_basket_page(self):71 basket_link = self.should_be_basket_link()72 print(f'Running method basket_link.click from page {self.url}')73 basket_link.click()74 self.url_should_contain('/basket/')75 def solve_quiz_and_get_code(self):76 alert = self.browser.switch_to.alert77 x = alert.text.split(" ")[2]78 answer = str(math.log(abs((12 * math.sin(float(x))))))79 alert.send_keys(answer)80 alert.accept()81 try:82 alert = self.browser.switch_to.alert83 alert_text = alert.text84 print(f"Your code: {alert_text}")85 alert.accept()86 except NoAlertPresentException:...
test_forms.py
Source:test_forms.py
...21 self.set_input("firstname", "Donald")22 self.set_input("lastname", "Duck")23 self.select_dropdown("cars", "Fiat")24 self.click_button("Submit")25 self.url_should_contain("firstname=Donald")26 self.url_should_not_contain("Mickey")27 self.url_should_contain("lastname=Duck")28 self.url_should_not_contain("Mouse")29class MissingFormTestCase(SeleniumLiveTestCase):30 selenium_timeout = 131 def test_missing_form(self):32 """ Look for a form that does not exist. """33 self.get_page("/")...
basket_page.py
Source:basket_page.py
...6 self.should_be_basket_url()7 self.should_be_no_item_in_basket()8 self.should_be_empty_basket_message()9 def should_be_basket_url(self):10 self.url_should_contain('/basket/')11 def should_be_no_item_in_basket(self):12 print('Verify that no items in basket...', end='')13 assert self.is_not_element_present(*BasketPageLocators.ITEM_IN_BASKET),\14 f'Opened basket_page from link {self.url}, and found some item in it. But should be empty.'15 print('Ok')16 def should_be_empty_basket_message(self):17 print('Verify "Empty basket message"...', end='')18 message_empty_basket = self.is_element_present(*BasketPageLocators.EMPTY_BASKET_MESSAGE)19 assert message_empty_basket,\20 f'Message "Empty basket" not found. Tried to find {BasketPageLocators.EMPTY_BASKET_MESSAGE}'...
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!!