@@ -60,7 +60,7 @@ completely loaded*::
60
60
61
61
driver.get("http://www.python.org")
62
62
63
- The next line is an assertion to confirm that title has "Python" word in it::
63
+ The next line is an assertion to confirm that title has the word "Python" in it::
64
64
65
65
assert "Python" in driver.title
66
66
@@ -73,7 +73,7 @@ chapter::
73
73
elem = driver.find_element(By.NAME, "q")
74
74
75
75
Next, we are sending keys, this is similar to entering keys using your keyboard.
76
- Special keys can be sent using `Keys ` class imported from
76
+ Special keys can be sent using the `Keys ` class imported from
77
77
`selenium.webdriver.common.keys `. To be safe, we'll first clear any
78
78
pre-populated text in the input field (e.g. "Search") so it doesn't affect our
79
79
search results::
@@ -87,9 +87,9 @@ ensure that some results are found, make an assertion::
87
87
88
88
assert "No results found." not in driver.page_source
89
89
90
- Finally, the browser window is closed. You can also call `quit ` method instead
91
- of `close `. The `quit ` will exit entire browser whereas `close ` will close one
92
- tab, but if just one tab was open, by default most browser will exit entirely.::
90
+ Finally, the browser window is closed. You can also call the `quit ` method instead
91
+ of `close `. The `quit ` method will exit the browser whereas `close ` will close one
92
+ tab, but if just one tab was open, by default most browsers will exit entirely.::
93
93
94
94
driver.close()
95
95
@@ -104,7 +104,7 @@ Python's unittest module. The other options for a tool/framework are `pytest
104
104
<https://nose.readthedocs.io/en/latest/> `_.
105
105
106
106
In this chapter, we use `unittest ` as the framework of choice. Here is the
107
- modified example which uses unittest module. This is a test for `python.org `
107
+ modified example which uses the unittest module. This is a test for the `python.org `
108
108
search functionality::
109
109
110
110
import unittest
@@ -149,17 +149,17 @@ Note: To run the above test in IPython or Jupyter, you should pass a couple of
149
149
arguments to the `main ` function as shown below::
150
150
151
151
unittest.main(argv=['first-arg-is-ignored'], exit=False)
152
-
152
+
153
153
154
154
155
155
Walkthrough of the example
156
156
~~~~~~~~~~~~~~~~~~~~~~~~~~
157
157
158
158
Initially, all the basic modules required are imported. The `unittest
159
159
<http://docs.python.org/library/unittest.html> `_ module is a built-in Python
160
- based on Java's JUnit. This module provides the framework for organizing the
160
+ module based on Java's JUnit. This module provides the framework for organizing the
161
161
test cases. The `selenium.webdriver ` module provides all the WebDriver
162
- implementations. Currently supported WebDriver implementations are Firefox,
162
+ implementations. Currently supported WebDriver implementations are: Firefox,
163
163
Chrome, IE and Remote. The `Keys ` class provides keys in the keyboard like
164
164
RETURN, F1, ALT etc. The `By ` class is used to locate elements within a document.
165
165
@@ -171,22 +171,22 @@ RETURN, F1, ALT etc. The `By` class is used to locate elements within a document
171
171
from selenium.webdriver.common.by import By
172
172
173
173
The test case class is inherited from `unittest.TestCase `. Inheriting from
174
- `TestCase ` class is the way to tell `unittest ` module that this is a test case::
174
+ the `TestCase ` class is the way to tell `unittest ` module that this is a test case::
175
175
176
176
class PythonOrgSearch(unittest.TestCase):
177
177
178
178
179
- The `setUp ` is part of initialization, this method will get called before every
179
+ The `setUp ` method is part of initialization. This method will get called before every
180
180
test function which you are going to write in this test case class. Here you
181
- are creating the instance of Firefox WebDriver.
181
+ are creating an instance of a Firefox WebDriver.
182
182
183
183
::
184
184
185
185
def setUp(self):
186
186
self.driver = webdriver.Firefox()
187
187
188
188
This is the test case method. The test case method should always start with
189
- characters `test `. The first line inside this method create a local reference
189
+ characters `test `. The first line inside this method creates a local reference
190
190
to the driver object created in `setUp ` method.
191
191
192
192
::
@@ -202,7 +202,7 @@ completely loaded*::
202
202
203
203
driver.get("http://www.python.org")
204
204
205
- The next line is an assertion to confirm that title has "Python" word in it::
205
+ The next line is an assertion to confirm that title has the word "Python" in it::
206
206
207
207
self.assertIn("Python", driver.title)
208
208
@@ -216,7 +216,7 @@ chapter::
216
216
elem = driver.find_element(By.NAME, "q")
217
217
218
218
Next, we are sending keys, this is similar to entering keys using your keyboard.
219
- Special keys can be send using `Keys ` class imported from
219
+ Special keys can be sent using the `Keys ` class imported from
220
220
`selenium.webdriver.common.keys `::
221
221
222
222
elem.send_keys("pycon")
@@ -229,9 +229,9 @@ is any. To ensure that some results are found, make an assertion::
229
229
230
230
The `tearDown ` method will get called after every test method. This is a place
231
231
to do all cleanup actions. In the current method, the browser window is closed.
232
- You can also call `quit ` method instead of `close `. The `quit ` will exit the
232
+ You can also call the `quit ` method instead of `close `. The `quit ` method will exit the
233
233
entire browser, whereas `close ` will close a tab, but if it is the only tab
234
- opened, by default most browser will exit entirely.::
234
+ opened, by default most browsers will exit entirely.::
235
235
236
236
def tearDown(self):
237
237
self.driver.close()
@@ -246,7 +246,7 @@ Final lines are some boiler plate code to run the test suite::
246
246
Using Selenium with remote WebDriver
247
247
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
248
248
249
- To use the remote WebDriver, you should have Selenium server running. To run
249
+ To use the remote WebDriver, you should have the Selenium server running. To run
250
250
the server, use this command::
251
251
252
252
java -jar selenium-server-standalone-2.x.x.jar
@@ -255,7 +255,7 @@ While running the Selenium server, you could see a message looking like this::
255
255
256
256
15:43:07.541 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub
257
257
258
- The above line says that you can use this URL for connecting to remote
258
+ The above line says that you can use this URL for connecting to the remote
259
259
WebDriver. Here are some examples::
260
260
261
261
from selenium import webdriver
@@ -273,7 +273,7 @@ WebDriver. Here are some examples::
273
273
command_executor='http://127.0.0.1:4444/wd/hub',
274
274
desired_capabilities=DesiredCapabilities.HTMLUNITWITHJS)
275
275
276
- The desired capabilities is a dictionary, so instead of using the default
276
+ The desired capabilities is a dictionary. So instead of using the default
277
277
dictionaries, you can specify the values explicitly::
278
278
279
279
driver = webdriver.Remote(
0 commit comments