Skip to content

Commit 92039e3

Browse files
committed
Update the ReadMe
1 parent d2caf6d commit 92039e3

File tree

1 file changed

+36
-27
lines changed

1 file changed

+36
-27
lines changed

README.md

Lines changed: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
<li><a href="#basic_example_and_usage"><strong>Basic Example & Usage</strong></a></li>
6767
<li><a href="#common_methods" ><strong>Common Test Methods</strong></a></li>
6868
<li><a href="#fun_facts" ><strong>Fun Facts / Learn More</strong></a></li>
69-
<li><a href="#demo_mode_and_debugging"><strong>Demo Mode and Debugging</strong></a></li>
69+
<li><a href="#demo_mode_and_debugging"><strong>Demo / Debug Modes</strong></a></li>
7070
<li><a href="#pytest_options" ><strong>Useful pytest Options</strong></a></li>
7171
<li><a href="#new_pytest_options" ><strong>SeleniumBase Options</strong></a></li>
7272
<li><a href="#directory_configuration"><strong>Directory Configuration</strong></a></li>
@@ -325,15 +325,15 @@ COMMANDS:
325325
```
326326
327327
328-
<h3><img src="https://seleniumbase.github.io/img/logo7.png" title="SeleniumBase" width="32" /> Downloading webdrivers:</h3>
328+
<h3>🔵 Downloading webdrivers:</h3>
329329
330330
✅ SeleniumBase automatically downloads webdrivers as needed, such as ``chromedriver``.
331331
332332
✅ To manually download a webdriver, see [Console Scripts](https://seleniumbase.io/seleniumbase/console_scripts/ReadMe/) OR [Webdriver Installation](https://seleniumbase.io/help_docs/webdriver_installation/).
333333
334334
335335
<a id="basic_example_and_usage"></a>
336-
<h3><img src="https://seleniumbase.github.io/img/logo7.png" title="SeleniumBase" width="32" /> Basic Example & Usage:</h3>
336+
<h2><img src="https://seleniumbase.github.io/img/logo7.png" title="SeleniumBase" width="32" /> Basic Example & Usage:</h2>
337337
338338
🔵 If you've cloned SeleniumBase, you can run tests from the [examples/](https://github.com/seleniumbase/SeleniumBase/tree/master/examples) folder.
339339
@@ -388,7 +388,7 @@ class MyTestClass(BaseCase):
388388
389389
390390
<a id="common_methods"></a>
391-
<h3><img src="https://seleniumbase.github.io/img/logo7.png" title="SeleniumBase" width="32" /> Here are some common SeleniumBase methods that you might find in tests:</h3>
391+
<h3><img src="https://seleniumbase.github.io/img/logo7.png" title="SeleniumBase" width="32" /> Here are some common SeleniumBase methods:</h3>
392392
393393
```python
394394
self.open(url) # Navigate the browser window to the URL.
@@ -498,7 +498,6 @@ pynose [FILE_NAME.py]:[CLASS_NAME].[METHOD_NAME]
498498
<h2><img src="https://seleniumbase.github.io/img/logo7.png" title="SeleniumBase" width="32" /> Detailed Instructions:</h2>
499499
500500
<a id="demo_mode_and_debugging"></a>
501-
<a id="seleniumbase_demo_mode"></a>
502501
🔵 <b>Demo Mode</b> helps you see what a test is doing. If a test is moving too fast for your eyes, run it in <b>Demo Mode</b>, which pauses the browser briefly between actions, highlights page elements being acted on, and displays assertions:
503502
504503
```bash
@@ -509,17 +508,23 @@ pytest my_first_test.py --demo
509508
510509
```python
511510
import time; time.sleep(5) # Makes the test wait and do nothing for 5 seconds.
512-
import pdb; pdb.set_trace() # Enter debugging mode. n = next, c = continue, s = step.
513-
import pytest; pytest.set_trace() # Enter debugging mode. n = next, c = continue, s = step.
511+
import pdb; pdb.set_trace() # Debug Mode. n: next, c: continue, s: step, u: up, d: down.
512+
import pytest; pytest.set_trace() # Debug Mode. n: next, c: continue, s: step, u: up, d: down.
514513
```
515514
516515
🔵 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:
517516
518517
```bash
519-
pytest my_first_test.py --pdb
518+
pytest test_fail.py --pdb
520519
```
521520
522-
(**``pdb``** console commands: ``n``, ``c``, ``s`` => ``next``, ``continue``, ``step``).
521+
🔵 To start tests in Debug Mode, add **``--trace``** as a ``pytest`` option:
522+
523+
```bash
524+
pytest test_coffee_cart.py --trace
525+
```
526+
527+
(**``pdb``** commands: ``n``, ``c``, ``s``, ``u``, ``d`` => ``next``, ``continue``, ``step``, ``up``, ``down``).
523528
524529
<a id="pytest_options"></a>
525530
🔵 Here are some useful command-line options that come with <code>pytest</code>:
@@ -655,7 +660,7 @@ Here's the command-line option to add to tests: (See [examples/custom_settings.p
655660
Inside your tests, you can use ``self.data`` to access that.
656661
657662
<a id="directory_configuration"></a>
658-
<h3><img src="https://seleniumbase.github.io/img/logo7.png" title="SeleniumBase" width="32" /> Directory Configuration:</h3>
663+
<h2><img src="https://seleniumbase.github.io/img/logo7.png" title="SeleniumBase" width="32" /> Directory Configuration:</h2>
659664
660665
🔵 When running tests with **pytest**, you'll want a copy of **[pytest.ini](https://github.com/seleniumbase/SeleniumBase/blob/master/pytest.ini)** in your root folders. When running tests with **pynose**, you'll want a copy of **[setup.cfg](https://github.com/seleniumbase/SeleniumBase/blob/master/setup.cfg)** in your root folders. These files specify default configuration details for tests. Folders should also include a blank ``__init__.py`` file, which allows your tests to import files from that folder.
661666
@@ -738,7 +743,7 @@ pytest test_fail.py
738743
--------
739744
740745
<a id="seleniumbase_dashboard"></a>
741-
<h3><img src="https://seleniumbase.github.io/img/logo7.png" title="SeleniumBase" width="32" /> SeleniumBase Dashboard:</h3>
746+
<h2><img src="https://seleniumbase.github.io/img/logo7.png" title="SeleniumBase" width="32" /> SeleniumBase Dashboard:</h2>
742747
743748
🔵 The ``--dashboard`` option for pytest generates a SeleniumBase Dashboard located at ``dashboard.html``, which updates automatically as tests run and produce results. Example:
744749
@@ -767,21 +772,21 @@ pytest test_suite.py --dashboard --rs --headless
767772
--------
768773
769774
<a id="creating_visual_reports"></a>
770-
<h3><img src="https://seleniumbase.github.io/img/logo7.png" title="SeleniumBase" width="32" /> Generating Test Reports:</h3>
775+
<h2><img src="https://seleniumbase.github.io/img/logo7.png" title="SeleniumBase" width="32" /> Generating Test Reports:</h2>
771776
772-
<h4><b>Pytest Reports:</b></h4>
777+
<h3>🔵 Pytest Reports:</h3>
773778
774-
🔵 Using ``--html=report.html`` gives you a fancy report of the name specified after your test suite completes.
779+
Using ``--html=report.html`` gives you a fancy report of the name specified after your test suite completes.
775780
776781
```bash
777782
pytest test_suite.py --html=report.html
778783
```
779784
780785
<img src="https://seleniumbase.github.io/cdn/img/html_report.png" alt="Example Pytest Report" title="Example Pytest Report" width="520" />
781786
782-
🔵 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.
787+
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.
783788
784-
🔵 Here's an example of an upgraded html report:
789+
Here's an example of an upgraded html report:
785790
786791
```bash
787792
pytest test_suite.py --dashboard --html=report.html
@@ -797,7 +802,7 @@ You can also use ``--junit-xml=report.xml`` to get an xml report instead. Jenkin
797802
pytest test_suite.py --junit-xml=report.xml
798803
```
799804
800-
<h4><b>pynose Reports:</b></h4>
805+
<h3>🔵 pynose Reports:</h3>
801806
802807
The ``--report`` option gives you a fancy report after your test suite completes.
803808
@@ -809,7 +814,7 @@ pynose test_suite.py --report
809814
810815
(NOTE: You can add ``--show-report`` to immediately display pynose reports after the test suite completes. Only use ``--show-report`` when running tests locally because it pauses the test run.)
811816
812-
<h4><b>Behave Dashboard & Reports:</b></h4>
817+
<h3>🔵 Behave Dashboard & Reports:</h4>
813818
814819
(The [behave_bdd/](https://github.com/seleniumbase/SeleniumBase/tree/master/examples/behave_bdd) folder can be found in the [examples/](https://github.com/seleniumbase/SeleniumBase/tree/master/examples) folder.)
815820
@@ -825,7 +830,7 @@ You can also use ``--junit`` to get ``.xml`` reports for each Behave feature. Je
825830
behave behave_bdd/features/ --junit -D rs -D headless
826831
```
827832
828-
<h4><b>Allure Reports:</b></h4>
833+
<h3>🔵 Allure Reports:</h3>
829834
830835
See: [https://docs.qameta.io/allure/](https://docs.qameta.io/allure/#_pytest)
831836
@@ -841,6 +846,7 @@ Now your tests can create Allure results files, which can be processed by Allure
841846
pytest test_suite.py --alluredir=allure_results
842847
```
843848
849+
--------
844850
845851
<h3><img src="https://seleniumbase.github.io/img/logo7.png" title="SeleniumBase" width="32" /> Using a Proxy Server:</h3>
846852
@@ -923,7 +929,7 @@ pytest [YOUR_TEST_FILE.py] --with-db-reporting --with-s3-logging
923929
<a id="detailed_method_specifications"></a>
924930
<h3><img src="https://seleniumbase.github.io/img/logo7.png" title="SeleniumBase" width="32" /> Detailed Method Specifications and Examples:</h3>
925931
926-
🔵 Navigating to a web page: (and related commands)
932+
<h4>🔵 Navigating to a web page: (and related commands)</h4>
927933
928934
```python
929935
self.open("https://xkcd.com/378/") # This method opens the specified page.
@@ -1106,7 +1112,7 @@ if self.is_link_text_visible("Stop! Hammer time!"):
11061112
self.click_link("Stop! Hammer time!")
11071113
```
11081114
1109-
🔵 Switching Tabs:
1115+
<h3>🔵 Switching Tabs:</h3>
11101116
11111117
<p>If your test opens up a new tab/window, you can switch to it. (SeleniumBase automatically switches to new tabs that don't open to <code>about:blank</code> URLs.)</p>
11121118
@@ -1123,7 +1129,7 @@ self.switch_to_frame('ContentManagerTextBody_ifr')
11231129
self.switch_to_default_content() # Exit the iframe when you're done
11241130
```
11251131
1126-
🔵 Executing Custom jQuery Scripts:
1132+
<h3>🔵 Executing Custom jQuery Scripts:</h3>
11271133
11281134
<p>jQuery is a powerful JavaScript library that allows you to perform advanced actions in a web browser.
11291135
If the web page you're on already has jQuery loaded, you can start executing jQuery scripts immediately.
@@ -1167,7 +1173,11 @@ self.execute_script("return jQuery('textarea')[2].value") # Returns the css "va
11671173
11681174
</details>
11691175
1170-
🔵 Some websites have a restrictive [Content Security Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP) to prevent users from loading jQuery and other external libraries onto their websites. If you need to use jQuery or another JS library on such a website, add ``--disable-csp`` on the command-line.
1176+
<h3>🔵 Handling a restrictive CSP:</h3>
1177+
1178+
🛑 Some websites have a restrictive [Content Security Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP) to prevent users from loading jQuery and other external libraries onto their websites. If you need to use jQuery or another JS library on such a website, add ``--disable-csp`` as a ``pytest`` command-line option.
1179+
1180+
<h3>🔵 More JavaScript fun:</h3>
11711181
11721182
<div></div>
11731183
<details>
@@ -1186,7 +1196,7 @@ self.click("a.analytics") # Clicks the generated button
11861196
11871197
</details>
11881198
1189-
🔵 Using deferred asserts:
1199+
<h3>🔵 Using deferred asserts:</h3>
11901200
11911201
<p>Let's say you want to verify multiple different elements on a web page in a single test, but you don't want the test to fail until you verified several elements at once so that you don't have to rerun the test to find more missing elements on the same page. That's where deferred asserts come in. Here's the example:</p>
11921202
@@ -1195,7 +1205,6 @@ from seleniumbase import BaseCase
11951205
BaseCase.main(__name__, __file__)
11961206
11971207
class MyTestClass(BaseCase):
1198-
11991208
def test_deferred_asserts(self):
12001209
self.open('https://xkcd.com/993/')
12011210
self.wait_for_element('#comic')
@@ -1211,7 +1220,7 @@ class MyTestClass(BaseCase):
12111220
<code>deferred_assert_element()</code> and <code>deferred_assert_text()</code> will save any exceptions that would be raised.
12121221
To flush out all the failed deferred asserts into a single exception, make sure to call <code>self.process_deferred_asserts()</code> at the end of your test method. If your test hits multiple pages, you can call <code>self.process_deferred_asserts()</code> before navigating to a new page so that the screenshot from your log files matches the URL where the deferred asserts were made.
12131222
1214-
🔵 Accessing Raw <a href="https://www.selenium.dev/documentation/webdriver/" target="_blank">WebDriver</a>:
1223+
<h3>🔵 Accessing Raw <a href="https://www.selenium.dev/documentation/webdriver/" target="_blank">WebDriver</a>:</h3>
12151224
12161225
<p>If you need access to any commands that come with standard <a href="https://www.selenium.dev/documentation/webdriver/" target="_blank">WebDriver</a>, you can call them directly like this:</p>
12171226
@@ -1223,7 +1232,7 @@ self.driver.find_elements("partial link text", "GitHub")
12231232
12241233
(In general, you'll want to use the SeleniumBase versions of methods when available.)
12251234
1226-
🔵 Retrying failing tests automatically:
1235+
<h3>🔵 How to retry failing tests automatically:</h3>
12271236
12281237
<p>You can use <code>--reruns=NUM</code> to retry failing tests that many times. Use <code>--reruns-delay=SECONDS</code> to wait that many seconds between retries. Example:</p>
12291238

0 commit comments

Comments
 (0)