|
|
@@ -1,4 +1,6 @@
|
|
|
from selenium import webdriver
|
|
|
+from selenium.webdriver.common.keys import Keys
|
|
|
+import time
|
|
|
import unittest
|
|
|
|
|
|
class NewVisitorTest(unittest.TestCase):
|
|
|
@@ -16,8 +18,33 @@ class NewVisitorTest(unittest.TestCase):
|
|
|
|
|
|
# She notices the page title and header mention to-do lists
|
|
|
self.assertIn('MovieLib', self.browser.title)
|
|
|
- self.fail('Finish the test!')
|
|
|
+ header_text = self.browser.find_element_by_tag_name('h1').text
|
|
|
+ self.assertIn('Your Movie list', header_text)
|
|
|
+
|
|
|
+ # She is invited to enter a to-do item straight away
|
|
|
+ inputbox = self.browser.find_element_by_id('input-new-movie')
|
|
|
+ self.assertEqual(
|
|
|
+ inputbox.get_attribute('placeholder'),
|
|
|
+ 'Enter a movie title'
|
|
|
+ )
|
|
|
+
|
|
|
+ # She types "Inception" into a text box
|
|
|
+ inputbox.send_keys('Inception')
|
|
|
|
|
|
+ # When she hits enter, the page updates, and now the page lists
|
|
|
+ # "1: Inception" as an item in a to-do list table
|
|
|
+ inputbox.send_keys(Keys.ENTER)
|
|
|
+ time.sleep(1)
|
|
|
+
|
|
|
+ table = self.browser.find_element_by_id('movie-table')
|
|
|
+ rows = table.find_elements_by_tag_name('tr')
|
|
|
+ self.assertTrue(
|
|
|
+ any(row.text == '1: Inception' for row in rows)
|
|
|
+ )
|
|
|
+
|
|
|
+ # There is still a text box inviting her to add another item. She
|
|
|
+ # enters "Armageddon"
|
|
|
+ self.fail('Finish the test!')
|
|
|
# She is invited to enter a to-do item straight away
|
|
|
|
|
|
if __name__ == '__main__':
|