Skip to content

Commit 94130d1

Browse files
committed
Update the documentation
1 parent e935ee8 commit 94130d1

File tree

2 files changed

+62
-61
lines changed

2 files changed

+62
-61
lines changed

help_docs/customizing_test_runs.md

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,11 @@ pytest verify_undetected.py --uc
103103
pytest my_first_test.py --settings-file=custom_settings.py
104104
```
105105

106-
🎛️ You can interchange ``pytest`` with ``nosetests`` for most tests, but using ``pytest`` is recommended. (``chrome`` is the default browser if not specified.)
106+
🎛️ You can interchange `pytest` with `nosetests` for most tests, but using `pytest` is recommended. (`chrome` is the default browser if not specified.)
107107

108-
🎛️ If you're using ``pytest`` for running tests outside of the SeleniumBase repo, you'll want a copy of [pytest.ini](https://github.com/seleniumbase/SeleniumBase/blob/master/pytest.ini) at the base of the new folder structure. If using ``nosetests``, the same applies for [setup.cfg](https://github.com/seleniumbase/SeleniumBase/blob/master/setup.cfg).
108+
🎛️ If you're using `pytest` for running tests outside of the SeleniumBase repo, you'll want a copy of [pytest.ini](https://github.com/seleniumbase/SeleniumBase/blob/master/pytest.ini) at the base of the new folder structure. If using `nosetests`, the same applies for [setup.cfg](https://github.com/seleniumbase/SeleniumBase/blob/master/setup.cfg).
109109

110-
🎛️ Here are some useful command-line options that come with ``pytest``:
110+
🎛️ Here are some useful command-line options that come with `pytest`:
111111

112112
```zsh
113113
-v # Verbose mode. Prints the full name of each test and shows more details.
@@ -124,7 +124,7 @@ pytest my_first_test.py --settings-file=custom_settings.py
124124
-m=MARKER # Run tests with the specified pytest marker.
125125
```
126126

127-
🎛️ SeleniumBase provides additional ``pytest`` command-line options for tests:
127+
🎛️ SeleniumBase provides additional `pytest` command-line options for tests:
128128

129129
```zsh
130130
--browser=BROWSER # (The web browser to use. Default: "chrome".)
@@ -232,7 +232,7 @@ pytest my_first_test.py --settings-file=custom_settings.py
232232

233233
(For more details, see the full list of command-line options **[here](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/plugins/pytest_plugin.py)**.)
234234

235-
🎛️ You can also view a list of popular ``pytest`` options for SeleniumBase by typing:
235+
🎛️ You can also view a list of popular `pytest` options for SeleniumBase by typing:
236236

237237
```zsh
238238
seleniumbase options
@@ -254,29 +254,29 @@ To see logging abilities, you can run a test suite that includes tests that fail
254254
pytest test_suite.py
255255
```
256256

257-
🔵 During test failures, logs and screenshots from the most recent test run will get saved to the ``latest_logs/`` folder. If ``--archive-logs`` is specified (or if ARCHIVE_EXISTING_LOGS is set to True in [settings.py](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/config/settings.py)), test logs will also get archived to the ``archived_logs/`` folder. Otherwise, the log files will be cleaned out when the next test run begins (by default).
257+
🔵 During test failures, logs and screenshots from the most recent test run will get saved to the `latest_logs/` folder. If `--archive-logs` is specified (or if ARCHIVE_EXISTING_LOGS is set to True in [settings.py](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/config/settings.py)), test logs will also get archived to the `archived_logs/` folder. Otherwise, the log files will be cleaned out when the next test run begins (by default).
258258

259259
<h3><img src="https://seleniumbase.github.io/img/green_logo.png" title="SeleniumBase" width="32" /> Demo Mode:</h3>
260260

261-
🔵 If any test is moving too fast for your eyes to see what's going on, 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:
261+
🔵 If any test is moving too fast for your eyes to see what's going on, 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:
262262

263263
```zsh
264264
pytest my_first_test.py --demo
265265
```
266266

267-
🔵 You can override the default wait time by either updating [settings.py](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/config/settings.py) or by using ``--demo-sleep=NUM`` when using Demo Mode. (NOTE: If you use ``--demo-sleep=NUM`` without using ``--demo``, nothing will happen.)
267+
🔵 You can override the default wait time by either updating [settings.py](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/config/settings.py) or by using `--demo-sleep=NUM` when using Demo Mode. (NOTE: If you use `--demo-sleep=NUM` without using `--demo`, nothing will happen.)
268268

269269
```zsh
270270
pytest my_first_test.py --demo --demo-sleep=1.2
271271
```
272272

273273
<h3><img src="https://seleniumbase.github.io/img/green_logo.png" title="SeleniumBase" width="32" /> Passing additional data to tests:</h3>
274274

275-
If you want to pass additional data from the command line to your tests, you can use ``--data=STRING``. Now inside your tests, you can use ``self.data`` to access that.
275+
If you want to pass additional data from the command line to your tests, you can use `--data=STRING`. Now inside your tests, you can use `self.data` to access that.
276276

277277
<h3><img src="https://seleniumbase.github.io/img/green_logo.png" title="SeleniumBase" width="32" /> Running tests multithreaded:</h3>
278278

279-
To run ``pytest`` with multiple processes, add ``-n=NUM``, ``-n NUM``, or ``-nNUM`` on the command line, where ``NUM`` is the number of CPUs you want to use.
279+
To run `pytest` with multiple processes, add `-n=NUM`, `-n NUM`, or `-nNUM` on the command line, where `NUM` is the number of CPUs you want to use.
280280

281281
```zsh
282282
pytest -n=8
@@ -302,30 +302,30 @@ import pdb; pdb.set_trace() # Debug Mode. n: next, c: continue, s: step, u: up,
302302
import pytest; pytest.set_trace() # Debug Mode. n: next, c: continue, s: step, u: up, d: down.
303303
```
304304

305-
🔵 To pause an active test that throws an exception or error, (*and keep the browser window open while **Debug Mode** begins in the console*), add **``--pdb``** as a ``pytest`` option:
305+
🔵 To pause an active test that throws an exception or error, (*and keep the browser window open while **Debug Mode** begins in the console*), add **`--pdb`** as a `pytest` option:
306306

307307
```zsh
308308
pytest test_fail.py --pdb
309309
```
310310

311-
🔵 To start tests in Debug Mode, add **``--trace``** as a ``pytest`` option:
311+
🔵 To start tests in Debug Mode, add **`--trace`** as a `pytest` option:
312312

313313
```zsh
314314
pytest test_coffee_cart.py --trace
315315
```
316316

317-
(**``pdb``** commands: ``n``, ``c``, ``s``, ``u``, ``d`` => ``next``, ``continue``, ``step``, ``up``, ``down``).
317+
(**`pdb`** commands: `n`, `c`, `s`, `u`, `d` => `next`, `continue`, `step`, `up`, `down`).
318318

319319
<h3><img src="https://seleniumbase.github.io/img/green_logo.png" title="SeleniumBase" width="32" /> Combinations of options:</h3>
320320

321321
🎛️ There are times when you'll want to combine various command-line options for added effect.
322-
For instance, the multi-process option, ``-n8``, can be customized by adding:
323-
``--dist=loadscope`` or ``--dist=loadfile`` to it.
322+
For instance, the multi-process option, `-n8`, can be customized by adding:
323+
`--dist=loadscope` or `--dist=loadfile` to it.
324324
There's more info on that here: [pytest-xdist](https://pypi.org/project/pytest-xdist/2.5.0/):
325325

326-
* ``-n8 --dist=loadscope``: Tests are grouped by module for test functions and by class for test methods. Groups are distributed to available workers as whole units. This guarantees that all tests in a group run in the same process. This can be useful if you have expensive module-level or class-level fixtures. Grouping by class takes priority over grouping by module.
326+
* `-n8 --dist=loadscope`: Tests are grouped by module for test functions and by class for test methods. Groups are distributed to available workers as whole units. This guarantees that all tests in a group run in the same process. This can be useful if you have expensive module-level or class-level fixtures. Grouping by class takes priority over grouping by module.
327327

328-
* ``-n8 --dist=loadfile``: Tests are grouped by their containing file. Groups are distributed to available workers as whole units. This guarantees that all tests in a file run in the same worker.
328+
* `-n8 --dist=loadfile`: Tests are grouped by their containing file. Groups are distributed to available workers as whole units. This guarantees that all tests in a file run in the same worker.
329329

330330
<details>
331331
<summary> ▶️ <code translate="no">-n8 --dist=loadgroup</code> (<b>click to expand</b>)</summary>
@@ -379,21 +379,21 @@ That makes your tests run very quickly in headless mode.
379379

380380
<h3><img src="https://seleniumbase.github.io/img/green_logo.png" title="SeleniumBase" width="32" /> The SeleniumBase Dashboard:</h3>
381381

382-
🔵 The ``--dashboard`` option for pytest generates a SeleniumBase Dashboard located at ``dashboard.html``, which updates automatically as tests run and produce results. Example:
382+
🔵 The `--dashboard` option for pytest generates a SeleniumBase Dashboard located at `dashboard.html`, which updates automatically as tests run and produce results. Example:
383383

384384
```zsh
385385
pytest --dashboard --rs --headless
386386
```
387387

388388
<img src="https://seleniumbase.github.io/cdn/img/dashboard_1.png" alt="The SeleniumBase Dashboard" title="The SeleniumBase Dashboard" width="360" />
389389

390-
🔵 Additionally, you can host your own SeleniumBase Dashboard Server on a port of your choice. Here's an example of that using Python 3's ``http.server``:
390+
🔵 Additionally, you can host your own SeleniumBase Dashboard Server on a port of your choice. Here's an example of that using Python 3's `http.server`:
391391

392392
```zsh
393393
python -m http.server 1948
394394
```
395395

396-
🔵 Now you can navigate to ``http://localhost:1948/dashboard.html`` in order to view the dashboard as a web app. This requires two different terminal windows: one for running the server, and another for running the tests, which should be run from the same directory. (Use <kbd>Ctrl+C</kbd> to stop the http server.)
396+
🔵 Now you can navigate to `http://localhost:1948/dashboard.html` in order to view the dashboard as a web app. This requires two different terminal windows: one for running the server, and another for running the tests, which should be run from the same directory. (Use <kbd>Ctrl+C</kbd> to stop the http server.)
397397

398398
🔵 Here's a full example of what the SeleniumBase Dashboard may look like:
399399

@@ -407,15 +407,15 @@ pytest test_suite.py --dashboard --rs --headless
407407

408408
<h3><img src="https://seleniumbase.github.io/img/green_logo.png" title="SeleniumBase" width="32" /> Pytest Reports:</h3>
409409

410-
🔵 Using ``--html=report.html`` gives you a fancy report of the name specified after your test suite completes.
410+
🔵 Using `--html=report.html` gives you a fancy report of the name specified after your test suite completes.
411411

412412
```zsh
413413
pytest test_suite.py --html=report.html
414414
```
415415

416416
<img src="https://seleniumbase.github.io/cdn/img/html_report.png" alt="Example Pytest Report" title="Example Pytest Report" width="520" />
417417

418-
🔵 When combining pytest html reports with SeleniumBase Dashboard usage, the pie chart from the Dashboard will get added to the html report. Additionally, if you set the html report URL to be the same as the Dashboard URL when also using the dashboard, (example: ``--dashboard --html=dashboard.html``), then the Dashboard will become an advanced html report when all the tests complete.
418+
🔵 When combining pytest html reports with SeleniumBase Dashboard usage, the pie chart from the Dashboard will get added to the html report. Additionally, if you set the html report URL to be the same as the Dashboard URL when also using the dashboard, (example: `--dashboard --html=dashboard.html`), then the Dashboard will become an advanced html report when all the tests complete.
419419

420420
🔵 Here's an example of an upgraded html report:
421421

@@ -427,7 +427,7 @@ pytest test_suite.py --dashboard --html=report.html
427427

428428
If viewing pytest html reports in [Jenkins](https://www.jenkins.io/), you may need to [configure Jenkins settings](https://stackoverflow.com/a/46197356/7058266) for the html to render correctly. This is due to [Jenkins CSP changes](https://www.jenkins.io/doc/book/system-administration/security/configuring-content-security-policy/).
429429

430-
You can also use ``--junit-xml=report.xml`` to get an xml report instead. Jenkins can use this file to display better reporting for your tests.
430+
You can also use `--junit-xml=report.xml` to get an xml report instead. Jenkins can use this file to display better reporting for your tests.
431431

432432
```zsh
433433
pytest test_suite.py --junit-xml=report.xml
@@ -437,15 +437,15 @@ pytest test_suite.py --junit-xml=report.xml
437437

438438
<h3><img src="https://seleniumbase.github.io/img/green_logo.png" title="SeleniumBase" width="32" /> Nosetest Reports:</h3>
439439

440-
The ``--report`` option gives you a fancy report after your test suite completes.
440+
The `--report` option gives you a fancy report after your test suite completes.
441441

442442
```zsh
443443
nosetests test_suite.py --report
444444
```
445445

446446
<img src="https://seleniumbase.github.io/cdn/img/nose_report.png" alt="Example Nosetest Report" title="Example Nosetest Report" width="320" />
447447

448-
(NOTE: You can add ``--show_report`` to immediately display Nosetest reports after the test suite completes. Only use ``--show_report`` when running tests locally because it pauses the test run.)
448+
(NOTE: You can add `--show_report` to immediately display Nosetest reports after the test suite completes. Only use `--show_report` when running tests locally because it pauses the test run.)
449449

450450
--------
451451

@@ -474,16 +474,16 @@ pytest --driver-version=VER
474474
The `VER` in `--driver-version=VER` can be:
475475
* A major driver version. Eg. `117`. (milestone)
476476
* An exact driver version. Eg. `117.0.5938.92`.
477-
* ``"browser"`` (exact match on browser version)
478-
* ``"keep"`` (keep using the driver you already have)
479-
* ``"latest"`` / ``"stable"`` (latest stable version)
480-
* ``"previous"`` / ``"latest-1"`` (latest minus one)
481-
* ``"beta"`` (latest beta version)
482-
* ``"dev"`` (latest dev version)
483-
* ``"canary"`` (latest canary version)
484-
* ``"mlatest"`` (latest version for the milestone)
477+
* `"browser"` (exact match on browser version)
478+
* `"keep"` (keep using the driver you already have)
479+
* `"latest"` / `"stable"` (latest stable version)
480+
* `"previous"` / `"latest-1"` (latest minus one)
481+
* `"beta"` (latest beta version)
482+
* `"dev"` (latest dev version)
483+
* `"canary"` (latest canary version)
484+
* `"mlatest"` (latest version for the milestone)
485485

486-
Note that different options could lead to the same result. (Eg. If you have the latest version of a browser for a milestone, then ``"browser"`` and ``"mlatest"`` should give you the same driver if the latest driver version for that milestone matches the browser version.)
486+
Note that different options could lead to the same result. (Eg. If you have the latest version of a browser for a milestone, then `"browser"` and `"mlatest"` should give you the same driver if the latest driver version for that milestone matches the browser version.)
487487

488488
--------
489489

@@ -575,7 +575,7 @@ pytest test_demo_site.py --server=USERNAME:KEY@ondemand.us-east-1.saucelabs.com
575575

576576
🌐 Or you can create your own Selenium Grid for test distribution. ([See this ReadMe for details](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/utilities/selenium_grid/ReadMe.md))
577577

578-
🌐 To use a server on the ``https`` protocol, add ``--protocol=https``: (*Now automatic if the port is 443.*)
578+
🌐 To use a server on the `https` protocol, add `--protocol=https`: (*Now automatic if the port is 443.*)
579579

580580
```zsh
581581
pytest test_demo_site.py --protocol=https --server=IP_ADDRESS --port=PORT
@@ -585,7 +585,7 @@ pytest test_demo_site.py --protocol=https --server=IP_ADDRESS --port=PORT
585585

586586
<h3><img src="https://seleniumbase.github.io/img/green_logo.png" title="SeleniumBase" width="32" /> Using a Proxy Server:</h3>
587587

588-
🌐 If you wish to use a proxy server for your browser tests (Chromium or Firefox), you can add ``--proxy=IP_ADDRESS:PORT`` as an argument on the command line.
588+
🌐 If you wish to use a proxy server for your browser tests (Chromium or Firefox), you can add `--proxy=IP_ADDRESS:PORT` as an argument on the command line.
589589

590590
```zsh
591591
pytest proxy_test.py --proxy=IP_ADDRESS:PORT
@@ -605,7 +605,7 @@ pytest proxy_test.py --proxy="socks4://IP_ADDRESS:PORT"
605605
pytest proxy_test.py --proxy="socks5://IP_ADDRESS:PORT"
606606
```
607607

608-
To make things easier, you can add your frequently-used proxies to PROXY_LIST in [proxy_list.py](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/config/proxy_list.py), and then use ``--proxy=KEY_FROM_PROXY_LIST`` to use the IP_ADDRESS:PORT of that key.
608+
To make things easier, you can add your frequently-used proxies to PROXY_LIST in [proxy_list.py](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/config/proxy_list.py), and then use `--proxy=KEY_FROM_PROXY_LIST` to use the IP_ADDRESS:PORT of that key.
609609

610610
```zsh
611611
pytest proxy_test.py --proxy=proxy1
@@ -615,15 +615,15 @@ pytest proxy_test.py --proxy=proxy1
615615

616616
<h3><img src="https://seleniumbase.github.io/img/green_logo.png" title="SeleniumBase" width="32" /> Changing the User-Agent:</h3>
617617

618-
🔤 If you wish to change the User-Agent for your browser tests (Chrome and Firefox only), you can add ``--agent="USER-AGENT-STRING"`` as an argument on the command line.
618+
🔤 If you wish to change the User-Agent for your browser tests (Chrome and Firefox only), you can add `--agent="USER-AGENT-STRING"` as an argument on the command line.
619619

620620
```zsh
621621
pytest user_agent_test.py --agent="Mozilla/5.0 (Nintendo 3DS; U; ; en) Version/1.7412.EU"
622622
```
623623

624624
<h3><img src="https://seleniumbase.github.io/img/green_logo.png" title="SeleniumBase" width="32" /> Mobile Device Testing:</h3>
625625

626-
📱 Use ``--mobile`` to quickly run your tests using Chrome's mobile device emulator with default values for device metrics (CSS Width, CSS Height, Pixel-Ratio) and a default value set for the user agent. To configure the mobile device metrics, use ``--metrics="CSS_Width,CSS_Height,Pixel_Ratio"`` to set those values. You'll also be able to set the user agent with ``--agent="USER-AGENT-STRING"`` (a default user agent will be used if not specified). To find real values for device metrics, [see this GitHub Gist](https://gist.github.com/sidferreira/3f5fad525e99b395d8bd882ee0fd9d00). For a list of available user agent strings, [check out this page](https://developers.whatismybrowser.com/useragents/explore/).
626+
📱 Use `--mobile` to quickly run your tests using Chrome's mobile device emulator with default values for device metrics (CSS Width, CSS Height, Pixel-Ratio) and a default value set for the user agent. To configure the mobile device metrics, use `--metrics="CSS_Width,CSS_Height,Pixel_Ratio"` to set those values. You'll also be able to set the user agent with `--agent="USER-AGENT-STRING"` (a default user agent will be used if not specified). To find real values for device metrics, [see this GitHub Gist](https://gist.github.com/sidferreira/3f5fad525e99b395d8bd882ee0fd9d00). For a list of available user agent strings, [check out this page](https://developers.whatismybrowser.com/useragents/explore/).
627627

628628
```zsh
629629
# Run tests using Chrome's mobile device emulator (default settings)

0 commit comments

Comments
 (0)