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
✅ SeleniumBase automatically downloads webdrivers as needed, such as ``chromedriver``.
331
331
332
332
✅ 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/).
333
333
334
334
335
335
<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>
337
337
338
338
🔵 If you've cloned SeleniumBase, you can run tests from the [examples/](https://github.com/seleniumbase/SeleniumBase/tree/master/examples) folder.
339
339
@@ -388,7 +388,7 @@ class MyTestClass(BaseCase):
388
388
389
389
390
390
<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>
392
392
393
393
```python
394
394
self.open(url) # Navigate the browser window to the URL.
🔵 <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:
🔵 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:
🔵 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.
🔵 The ``--dashboard`` option for pytest generates a SeleniumBase Dashboard located at ``dashboard.html``, which updates automatically as tests run and produce results. Example:
🔵 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.
@@ -797,7 +802,7 @@ You can also use ``--junit-xml=report.xml`` to get an xml report instead. Jenkin
797
802
pytest test_suite.py --junit-xml=report.xml
798
803
```
799
804
800
-
<h4><b>pynose Reports:</b></h4>
805
+
<h3>🔵 pynose Reports:</h3>
801
806
802
807
The ``--report`` option gives you a fancy report after your test suite completes.
803
808
@@ -809,7 +814,7 @@ pynose test_suite.py --report
809
814
810
815
(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.)
811
816
812
-
<h4><b>Behave Dashboard & Reports:</b></h4>
817
+
<h3>🔵 Behave Dashboard & Reports:</h4>
813
818
814
819
(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.)
815
820
@@ -825,7 +830,7 @@ You can also use ``--junit`` to get ``.xml`` reports for each Behave feature. Je
<h3><img src="https://seleniumbase.github.io/img/logo7.png" title="SeleniumBase" width="32" /> Detailed Method Specifications and Examples:</h3>
925
931
926
-
🔵 Navigating to a web page: (and related commands)
932
+
<h4>🔵 Navigating to a web page: (and related commands)</h4>
927
933
928
934
```python
929
935
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!"):
1106
1112
self.click_link("Stop! Hammer time!")
1107
1113
```
1108
1114
1109
-
🔵 Switching Tabs:
1115
+
<h3>🔵 Switching Tabs:</h3>
1110
1116
1111
1117
<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>
🔵 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>
1171
1181
1172
1182
<div></div>
1173
1183
<details>
@@ -1186,7 +1196,7 @@ self.click("a.analytics") # Clicks the generated button
1186
1196
1187
1197
</details>
1188
1198
1189
-
🔵 Using deferred asserts:
1199
+
<h3>🔵 Using deferred asserts:</h3>
1190
1200
1191
1201
<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>
1192
1202
@@ -1195,7 +1205,6 @@ from seleniumbase import BaseCase
1195
1205
BaseCase.main(__name__, __file__)
1196
1206
1197
1207
class MyTestClass(BaseCase):
1198
-
1199
1208
def test_deferred_asserts(self):
1200
1209
self.open('https://xkcd.com/993/')
1201
1210
self.wait_for_element('#comic')
@@ -1211,7 +1220,7 @@ class MyTestClass(BaseCase):
1211
1220
<code>deferred_assert_element()</code> and <code>deferred_assert_text()</code> will save any exceptions that would be raised.
1212
1221
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.
1213
1222
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>
1215
1224
1216
1225
<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>
1217
1226
@@ -1223,7 +1232,7 @@ self.driver.find_elements("partial link text", "GitHub")
1223
1232
1224
1233
(In general, you'll want to use the SeleniumBase versions of methods when available.)
1225
1234
1226
-
🔵 Retrying failing tests automatically:
1235
+
<h3>🔵 How to retry failing tests automatically:</h3>
1227
1236
1228
1237
<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>
0 commit comments