@@ -89,6 +89,9 @@ write our FT to look for a "My Lists" page:
89
89
====
90
90
[source,python]
91
91
----
92
+ from selenium.webdriver.common.by import By
93
+ [...]
94
+
92
95
def test_logged_in_users_lists_are_saved_as_my_lists(self):
93
96
# Edith is a logged-in user
94
97
self.create_pre_authenticated_session("[email protected] ")
@@ -100,14 +103,14 @@ write our FT to look for a "My Lists" page:
100
103
first_list_url = self.browser.current_url
101
104
102
105
# She notices a "My lists" link, for the first time.
103
- self.browser.find_element_by_link_text( "My lists").click()
106
+ self.browser.find_element(By.LINK_TEXT, "My lists").click()
104
107
105
108
# She sees that her list is in there, named according to its
106
109
# first list item
107
110
self.wait_for(
108
- lambda: self.browser.find_element_by_link_text( "Reticulate splines")
111
+ lambda: self.browser.find_element(By.LINK_TEXT, "Reticulate splines")
109
112
)
110
- self.browser.find_element_by_link_text( "Reticulate splines").click()
113
+ self.browser.find_element(By.LINK_TEXT, "Reticulate splines").click()
111
114
self.wait_for(
112
115
lambda: self.assertEqual(self.browser.current_url, first_list_url)
113
116
)
@@ -142,21 +145,21 @@ we check that only logged-in users can see the "My Lists" page:
142
145
second_list_url = self.browser.current_url
143
146
144
147
# Under "my lists", her new list appears
145
- self.browser.find_element_by_link_text("My lists").click()
146
- self.wait_for(
147
- lambda: self.browser.find_element_by_link_text("Click cows")
148
- )
149
- self.browser.find_element_by_link_text("Click cows").click()
148
+ self.browser.find_element(By.LINK_TEXT, "My lists").click()
149
+ self.wait_for(lambda: self.browser.find_element(By.LINK_TEXT, "Click cows"))
150
+ self.browser.find_element(By.LINK_TEXT, "Click cows").click()
150
151
self.wait_for(
151
152
lambda: self.assertEqual(self.browser.current_url, second_list_url)
152
153
)
153
154
154
155
# She logs out. The "My lists" option disappears
155
- self.browser.find_element_by_link_text("Log out").click()
156
- self.wait_for(lambda: self.assertEqual(
157
- self.browser.find_elements_by_link_text("My lists"),
158
- [],
159
- ))
156
+ self.browser.find_element(By.LINK_TEXT, "Log out").click()
157
+ self.wait_for(
158
+ lambda: self.assertEqual(
159
+ self.browser.find_elements(By.LINK_TEXT, "My lists"),
160
+ [],
161
+ )
162
+ )
160
163
----
161
164
====
162
165
@@ -204,7 +207,7 @@ The first error should look like this:
204
207
205
208
[subs="specialcharacters,macros"]
206
209
----
207
- $ pass:quotes[*python3 manage.py test functional_tests.test_my_lists*]
210
+ $ pass:quotes[*python3 src/ manage.py test functional_tests.test_my_lists*]
208
211
[...]
209
212
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate
210
213
element: My lists
@@ -243,7 +246,7 @@ the next failure:
243
246
244
247
[subs="specialcharacters,macros"]
245
248
----
246
- $ pass:quotes[*python3 manage.py test functional_tests.test_my_lists*]
249
+ $ pass:quotes[*python3 src/ manage.py test functional_tests.test_my_lists*]
247
250
[...]
248
251
lambda: self.browser.find_element_by_link_text('Reticulate splines')
249
252
[...]
@@ -358,7 +361,7 @@ them to be clickable links named after the first item:
358
361
359
362
[subs="specialcharacters,macros"]
360
363
----
361
- $ pass:quotes[*python3 manage.py test functional_tests.test_my_lists*]
364
+ $ pass:quotes[*python3 src/ manage.py test functional_tests.test_my_lists*]
362
365
[...]
363
366
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate
364
367
element: Reticulate splines
@@ -499,7 +502,7 @@ we've got any further:
499
502
500
503
[subs="specialcharacters,macros"]
501
504
----
502
- $ pass:quotes[*python manage.py test functional_tests*]
505
+ $ pass:quotes[*python src/ manage.py test functional_tests*]
503
506
[...]
504
507
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate
505
508
element: Reticulate splines
@@ -802,7 +805,7 @@ Because we need to make some migrations:
802
805
803
806
[subs="specialcharacters,macros"]
804
807
----
805
- $ pass:quotes[*python manage.py makemigrations*]
808
+ $ pass:quotes[*python src/ manage.py makemigrations*]
806
809
Migrations for 'lists':
807
810
lists/migrations/0006_list_owner.py
808
811
- Add field owner to list
@@ -856,7 +859,7 @@ And that gets us passing!
856
859
857
860
[subs="specialcharacters,macros"]
858
861
----
859
- $ pass:quotes[*python manage.py test lists*]
862
+ $ pass:quotes[*python src/ manage.py test lists*]
860
863
[...]
861
864
.......................................
862
865
---------------------------------------------------------------------
@@ -912,7 +915,7 @@ and a working "My Lists" page (<<my-lists-page>>)!
912
915
913
916
[subs="specialcharacters,macros"]
914
917
----
915
- $ pass:quotes[*python manage.py test functional_tests*]
918
+ $ pass:quotes[*python src/ manage.py test functional_tests*]
916
919
[...]
917
920
Ran 8 tests in 93.819s
918
921
0 commit comments