|
| 1 | +import unittest, time, re |
| 2 | +import base_test |
| 3 | +from selenium import webdriver |
| 4 | + |
| 5 | +from selenium.webdriver.common.keys import Keys |
| 6 | + |
| 7 | +class LambdaTest(base_test.BaseTest): |
| 8 | + |
| 9 | + def test_unit_user_should_able_to_add_item(self): |
| 10 | + |
| 11 | + # try: |
| 12 | + |
| 13 | + driver = self.driver |
| 14 | + |
| 15 | + # Url |
| 16 | + |
| 17 | + driver.get(self.base_url) |
| 18 | + |
| 19 | + # Click on check box |
| 20 | + |
| 21 | + check_box_one = driver.find_element_by_name("li1") |
| 22 | + |
| 23 | + check_box_one.click() |
| 24 | + |
| 25 | + # Click on check box |
| 26 | + |
| 27 | + check_box_two = driver.find_element_by_name("li2") |
| 28 | + |
| 29 | + check_box_two.click() |
| 30 | + |
| 31 | + # Enter item in textfield |
| 32 | + |
| 33 | + textfield = driver.find_element_by_id("sampletodotext") |
| 34 | + |
| 35 | + textfield.send_keys("Yey, Let's add it to list") |
| 36 | + |
| 37 | + # Click on add button |
| 38 | + |
| 39 | + add_button = driver.find_element_by_id("addbutton") |
| 40 | + |
| 41 | + add_button.click() |
| 42 | + |
| 43 | + # Verified added item |
| 44 | + |
| 45 | + added_item = driver.find_element_by_xpath("/html/body/div/div/div/ul/li[6]/span").text |
| 46 | + |
| 47 | + print (added_item) |
| 48 | + |
| 49 | + #Assertion |
| 50 | + if "Yey, Let's add it to list" in added_item: |
| 51 | + driver.execute_script("lambda-status=passed") |
| 52 | + |
| 53 | + else: |
| 54 | + driver.execute_script("lambda-status=failed") |
| 55 | + |
| 56 | + |
| 57 | + |
| 58 | + |
| 59 | + |
| 60 | +if __name__ == "__main__": |
| 61 | + |
| 62 | + unittest.main() |
0 commit comments