You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Chrome is the default browser if not specified with ``--browser=BROWSER``.
101
106
* On Linux ``--headless`` is the default behavior (running with no GUI). You can also run in headless mode on any OS. If your Linux machine has a GUI and you want to see the web browser as tests run, add ``--headed`` or ``--gui``.
102
107
@@ -185,8 +190,7 @@ As you can see, the old WebDriver way is very bad!
185
190
Use SeleniumBase to make testing much easier!
186
191
(You can still use ``self.driver`` in your code.)
187
192
188
-
* Run tests with ``pytest`` or ``nosetests`` in any browser:
189
-
(**pytest** is recommended. **Chrome** is the default browser.)
193
+
You can interchange ``pytest`` with ``nosetests`` for most tests, but using ``pytest`` is recommended. (``chrome`` is the default browser if not specified.)
190
194
191
195
```bash
192
196
pytest my_first_test.py --browser=chrome
@@ -229,7 +233,7 @@ seleniumbase install iedriver
229
233
seleniumbase install operadriver
230
234
```
231
235
232
-
Next, choose between **pytest** and **nosetests** test runners. (<i>Mostly interchangeable.</i>)
236
+
Next, choose between ``pytest`` and ``nosetests`` test runners. (<i>Mostly interchangeable.</i>)
(<i>If no browser is specified, Chrome is used by default.</i>)
243
247
With Pytest, a green dot means a test passed. An "F" means a test failed.
244
248
245
-
<aid="seleniumbase_demo_mode"></a> **Use Demo Mode to help you see what tests are asserting.**
249
+
<aid="seleniumbase_demo_mode"></a> <b>Use Demo Mode to help you see what tests are asserting.</b>
246
250
247
251
If the example test is moving too fast for your eyes, you can run it in **Demo Mode** by adding ``--demo`` on the command-line, which pauses the browser briefly between actions, highlights page elements being acted on, and lets you know what test assertions are happening in real time:
248
252
249
253
```bash
250
254
pytest my_first_test.py --demo
251
255
```
252
256
253
-
**Pytest** includes test discovery. If you don't specify a specific file or folder to run from, ``pytest`` will search all subdirectories automatically for tests to run based on the following matching criteria:
257
+
``Pytest`` includes test discovery. If you don't specify a specific file or folder to run from, ``pytest`` will search all subdirectories automatically for tests to run based on the following matching criteria:
254
258
Python filenames that start with ``test_`` or end with ``_test.py``.
255
259
Python methods that start with ``test_``.
256
260
The Python class name can be anything since SeleniumBase's ``BaseCase`` class inherits from the ``unittest.TestCase`` class.
@@ -260,27 +264,27 @@ You can see which tests are getting discovered by ``pytest`` by using:
260
264
pytest --collect-only -q
261
265
```
262
266
263
-
You can use the following in your scripts to help you debug issues:
264
-
(<i>If using ipdb, make sure you add "-s" to command-line options unless already in pytest.ini</i>)
267
+
You can use the following calls in your scripts to help you debug issues:
268
+
265
269
```python
266
270
import time; time.sleep(5) # Makes the test wait and do nothing for 5 seconds.
267
271
import ipdb; ipdb.set_trace() # Enter debugging mode. n = next, c = continue, s = step.
268
272
import pytest; pytest.set_trace() # Enter debugging mode. n = next, c = continue, s = step.
269
273
```
270
274
271
-
<b>To pause an active test that throws an exception or error, add ``--pdb -s``:</b>
275
+
To pause an active test that throws an exception or error, add ``--pdb``:
272
276
273
277
```bash
274
-
pytest my_first_test.py --pdb -s
278
+
pytest my_first_test.py --pdb
275
279
```
276
280
277
281
The code above will leave your browser window open in case there's a failure. (ipdb commands: 'n', 'c', 's' => next, continue, step).
278
282
279
-
Here are some useful command-line options that come with Pytest:
283
+
Here are some useful command-line options that come with ``pytest``:
280
284
281
285
```bash
282
-
-v #Prints the full test name for each test.
283
-
-q #Prints fewer details in the console output when running tests.
286
+
-v #Verbose mode. Print the full name of each test run.
287
+
-q #Quiet mode. Print fewer details in the console output when running tests.
284
288
-x # Stop running the tests after the first failure is reached.
285
289
--html=report.html # Creates a detailed pytest-html report after tests finish.
286
290
--collect-only # Show what tests would get run without actually running them.
@@ -291,52 +295,52 @@ Here are some useful command-line options that come with Pytest:
291
295
-m=MARKER # Only run tests that are marked with the specified pytest marker.
292
296
```
293
297
294
-
SeleniumBase provides additional Pytest command-line options for tests:
298
+
SeleniumBase provides additional ``pytest`` command-line options for tests:
295
299
296
300
```bash
297
-
--browser=BROWSER # (The web browser to use.)
301
+
--browser=BROWSER # (The web browser to use. Default: "chrome")
298
302
--cap-file=FILE # (The web browser's desired capabilities to use.)
299
303
--cap-string=STRING # (The web browser's desired capabilities to use.)
0 commit comments