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
Copy file name to clipboardExpand all lines: README.md
+40-40Lines changed: 40 additions & 40 deletions
Original file line number
Diff line number
Diff line change
@@ -134,7 +134,7 @@ class MyTestClass(BaseCase):
134
134
135
135
<palign="left">📗 Here's <ahref="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_coffee_cart.py"target="_blank">test_coffee_cart.py</a>, which verifies an e-commerce site:</p>
<palign="left">📗 Here's <ahref="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_demo_site.py"target="_blank">test_demo_site.py</a>, which covers several actions:</p>
150
150
151
-
```bash
151
+
```zsh
152
152
pytest test_demo_site.py
153
153
```
154
154
@@ -296,7 +296,7 @@ finally:
296
296
297
297
🔵 **How to install ``seleniumbase`` from PyPI:**
298
298
299
-
```bash
299
+
```zsh
300
300
pip install seleniumbase
301
301
```
302
302
@@ -306,22 +306,22 @@ pip install seleniumbase
306
306
307
307
🔵 **How to install ``seleniumbase`` from a GitHub clone:**
Most SeleniumBase scripts can be run with <code translate="no">pytest</code>, <code translate="no">pynose</code>, or pure <code translate="no">python</code>. Not all test runners can run all test formats. For example, tests that use the ``sb`` pytest fixture can only be run with ``pytest``. (See <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/syntax_formats.md">Syntax Formats</a>) There's also a <a href="https://behave.readthedocs.io/en/stable/gherkin.html#features" target="_blank">Gherkin</a> test format that runs with <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/behave_bdd/ReadMe.md">behave</a>.
🔵 <b>Demo Mode</b> helps you see what a test is doing. If a test is moving too fast foryour eyes, run itin<b>Demo Mode</b> to pause the browser briefly between actions, highlight page elements being acted on, and display 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:
586
586
587
-
```bash
587
+
```zsh
588
588
pytest test_fail.py --pdb
589
589
```
590
590
591
591
🔵 To start tests in Debug Mode, add **``--trace``** as a ``pytest`` option:
🔵 During test failures, logs and screenshots from the most recent test run will get saved to the ``latest_logs/`` folder. Those logs will get moved to ``archived_logs/``if you add --archive_logs to command-line options, or have ``ARCHIVE_EXISTING_LOGS``set to True in [settings.py](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/config/settings.py), otherwise log files with be cleaned up at the start of the next test run. The ``test_suite.py`` collection contains tests that fail on purpose so that you can see how logging works.
733
733
734
-
```bash
734
+
```zsh
735
735
cd examples/
736
736
737
737
pytest test_suite.py --chrome
@@ -754,13 +754,13 @@ Inside your tests, you can use ``self.data`` to access that.
754
754
755
755
🔵 ``sbase mkdir DIR`` creates a folder with config files and sample tests:
756
756
757
-
```bash
757
+
```zsh
758
758
sbase mkdir ui_tests
759
759
```
760
760
761
761
> That new folder will have these files:
762
762
763
-
```bash
763
+
```zsh
764
764
ui_tests/
765
765
├── __init__.py
766
766
├── my_first_test.py
@@ -786,13 +786,13 @@ ui_tests/
786
786
787
787
<b>ProTip™:</b> You can also create a boilerplate folder without any sample tests in it by adding ``-b`` or ``--basic`` to the ``sbase mkdir`` command:
788
788
789
-
```bash
789
+
```zsh
790
790
sbase mkdir ui_tests --basic
791
791
```
792
792
793
793
> That new folder will have these files:
794
794
795
-
```bash
795
+
```zsh
796
796
ui_tests/
797
797
├── __init__.py
798
798
├── pytest.ini
@@ -822,7 +822,7 @@ class MyTestClass(BaseCase):
822
822
823
823
You can run it from the ``examples/`` folder like this:
824
824
825
-
```bash
825
+
```zsh
826
826
pytest test_fail.py
827
827
```
828
828
@@ -835,23 +835,23 @@ pytest test_fail.py
835
835
836
836
🔵 The ``--dashboard`` option for pytest generates a SeleniumBase Dashboard located at ``dashboard.html``, which updates automatically as tests run and produce results. Example:
🔵 Additionally, you can host your own SeleniumBase Dashboard Server on a port of your choice. Here's an example of that using Python's ``http.server``:
845
845
846
-
```bash
846
+
```zsh
847
847
python -m http.server 1948
848
848
```
849
849
850
850
🔵 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.)
851
851
852
852
🔵 Here's a full example of what the SeleniumBase Dashboard may look like:
(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.)
You can also use ``--junit`` to get ``.xml`` reports for each <code translate="no">behave</code> feature. Jenkins can use these files to display better reporting for your tests.
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.
942
942
943
-
```bash
943
+
```zsh
944
944
pytest proxy_test.py --proxy=IP_ADDRESS:PORT
945
945
```
946
946
947
947
If the proxy server that you wish to use requires authentication, you can do the following (Chromium only):
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.
🔵 If you wish to change the User-Agent for your browser tests (Chromium and Firefox only), you can add ``--agent="USER AGENT STRING"`` as an argument on the command-line.
@@ -1354,7 +1354,7 @@ self.driver.find_elements("partial link text", "GitHub")
1354
1354
1355
1355
<p>You can use <code translate="no">pytest --reruns=NUM</code> to retry failing tests that many times. Add <code translate="no">--reruns-delay=SECONDS</code> to wait that many seconds between retries. Example:</p>
0 commit comments