5.4 Three Strikes and Refactor
parent
9bacbfef4c
commit
87834f5a0b
|
@ -11,6 +11,11 @@ class NewVisitorTest(unittest.TestCase):
|
|||
def tearDown(self):
|
||||
self.browser.quit()
|
||||
|
||||
def check_for_row_in_list_table(self, row_text):
|
||||
table = self.browser.find_element_by_id('id_list_table')
|
||||
rows = table.find_elements_by_tag_name('tr')
|
||||
self.assertIn(row_text, [row.text for row in rows])
|
||||
|
||||
def test_can_start_a_list_and_retrieve_it_later(self):
|
||||
# Edith has heard about a cool new online to-do app. She goes
|
||||
# to check out its homepage
|
||||
|
@ -36,9 +41,7 @@ class NewVisitorTest(unittest.TestCase):
|
|||
# "1: Buy peacock feathers" as an item in a to-do list
|
||||
inputbox.send_keys(Keys.ENTER)
|
||||
time.sleep(1)
|
||||
table = self.browser.find_element_by_id('id_list_table')
|
||||
rows = table.find_elements_by_tag_name('tr')
|
||||
# self.assertTrue('1: Buy peacock feathers', [row.text for row in rows])
|
||||
self.check_for_row_in_list_table('1: Buy peacock feathers')
|
||||
|
||||
# There is still a text box inviting her to add another item. She
|
||||
# enters "Use peacock feathers to make a fly" (Edith is very methodical)
|
||||
|
@ -48,14 +51,8 @@ class NewVisitorTest(unittest.TestCase):
|
|||
time.sleep(1)
|
||||
|
||||
# The page updates again, and now shows both items on her list
|
||||
table = self.browser.find_element_by_id('id_list_table')
|
||||
rows = table.find_elements_by_tag_name('tr')
|
||||
print(rows)
|
||||
self.assertIn('1: Buy peacock feathers', [row.text for row in rows])
|
||||
self.assertIn(
|
||||
'2: Use peacock feathers to make a fly',
|
||||
[row.text for row in rows]
|
||||
)
|
||||
self.check_for_row_in_list_table('1: Buy peacock feathers')
|
||||
self.check_for_row_in_list_table('2: Use peacock feathers to make a fly')
|
||||
|
||||
# Edith wonders whether the site will remember her list. Then she sees
|
||||
# that the site has generated a unique URL for her -- there is some
|
||||
|
|
Loading…
Reference in New Issue