diff --git a/functional_tests.py b/functional_tests.py index e09c241..508ee25 100644 --- a/functional_tests.py +++ b/functional_tests.py @@ -36,16 +36,26 @@ class NewVisitorTest(unittest.TestCase): table = self.browser.find_element(By.ID, "id_list_table") rows = table.find_elements(By.TAG_NAME, "tr") - self.assertTrue( - any(row.text == "1: Buy peacock feathers" for row in rows), - "New to-do item did not appear in table", - ) + self.assertIn("1: Buy peacock feathers", [row.text for row in rows]) # There is still a text box inviting him to add another item. # He enters "Use peacock feathers to make a fly" (Ig is very methodical) - self.fail("Finish the test!") + inputbox = self.browser.find_element(By.ID, "id_new_item") + inputbox.send_keys("Use peacock feathers to make a fly") + inputbox.send_keys(Keys.ENTER) + time.sleep(1) # The page updates again, and now shows both items on his list + table = self.browser.find_element(By.ID, "id_list_table") + rows = table.find_elements(By.TAG_NAME, "tr") + self.assertIn( + "1: Buy peacock feathers", + [row.text for row in rows], + ) + self.assertIn( + "2: Use peacock feather sto make a fly", + [row.text for row in rows], + ) # Satisfied, he goes back to sleep diff --git a/lists/templates/home.html b/lists/templates/home.html index 3a9209d..c5df936 100644 --- a/lists/templates/home.html +++ b/lists/templates/home.html @@ -4,9 +4,12 @@
1: {{ new_item_text }} |