@@ -20,6 +20,7 @@ from Python like this.
20
20
elem = driver.find_element_by_name("q")
21
21
elem.send_keys("pycon")
22
22
elem.send_keys(Keys.RETURN)
23
+ assert "No results found." not in driver.page_source
23
24
driver.close()
24
25
25
26
The above script can be saved into a file (eg:-
@@ -77,7 +78,10 @@ keyboard. Special keys can be send using `Keys` class imported from
77
78
elem.send_keys("pycon")
78
79
elem.send_keys(Keys.RETURN)
79
80
80
- After submission of the page, you should get the result if there is any::
81
+ After submission of the page, you should get the result if there is any.
82
+ To ensure that some results are found, make an assertion::
83
+
84
+ assert "No results found." not in driver.page_source
81
85
82
86
Finally, the browser window is closed. You can also call `quit `
83
87
method instead of `close `. The `quit ` will exit entire browser where
@@ -114,6 +118,7 @@ for `python.org` search functionality::
114
118
self.assertIn("Python", driver.title)
115
119
elem = driver.find_element_by_name("q")
116
120
elem.send_keys("pycon")
121
+ assert "No results found." not in driver.page_source
117
122
elem.send_keys(Keys.RETURN)
118
123
119
124
def tearDown(self):
@@ -208,7 +213,10 @@ keyboard. Special keys can be send using `Keys` class imported from
208
213
elem.send_keys(Keys.RETURN)
209
214
210
215
After submission of the page, you should get result as per search if
211
- there is any.
216
+ there is any. To ensure that some results are found, make an
217
+ assertion::
218
+
219
+ assert "No results found." not in driver.page_source
212
220
213
221
The `tearDown ` method will get called after every test method. This
214
222
is a place to do all cleanup actions. In the current method, the
0 commit comments