webdriver-test.py (751B)
1 import unittest 2 from selenium import webdriver 3 from selenium.webdriver.common.by import By 4 5 class WebDriverPythonBasics(unittest.TestCase): 6 7 8 def setUp(self): 9 self.browser = webdriver.Chrome() 10 11 12 def test_saucelabs_homepage_header_displayed(self): 13 self.browser.get("https://www.saucelabs.com") 14 element = self.browser.find_element(By.XPATH, '//a[text()="Platforms"]'); 15 self.assertTrue(element.is_displayed()); 16 element.click(); 17 pricing_link = self.browser.find_element(By.XPATH, '//a[text()="Pricing"]'); 18 self.assertTrue(pricing_link.is_displayed()); 19 pricing_link.click(); 20 21 22 def tearDown(self): 23 self.browser.close() 24 25 26 if __name__ == '__main__': 27 unittest.main() 28