Best Python code snippet using SeleniumBase
test_swag_labs.py
Source:test_swag_labs.py
...9 self.update_text("#password", "secret_sauce")10 self.click('input[type="submit"]')11 self.assert_element("#inventory_container")12 self.assert_text("Products", "div.product_label")13 def test_swag_labs_basic_flow(self):14 """ This test checks basic functional flow in the Swag Labs store. """15 self.login()16 # Verify that the "Test.allTheThings() T-Shirt" appears on the page17 item_name = "Test.allTheThings() T-Shirt"18 self.assert_text(item_name)19 # Verify that a reverse-alphabetical sort works as expected20 self.select_option_by_value("select.product_sort_container", "za")21 if item_name not in self.get_text("div.inventory_item"):22 raise Exception('Sort Failed! Expecting "%s" on top!' % item_name)23 # Add the "Test.allTheThings() T-Shirt" to the cart24 self.assert_exact_text("ADD TO CART", "button.btn_inventory")25 item_price = self.get_text("div.inventory_item_price")26 self.click("button.btn_inventory")27 self.assert_exact_text("REMOVE", "button.btn_inventory")...
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!!