Skip to content

Commit 6bfea8b

Browse files
committed
Update the documentation
1 parent ab2de31 commit 6bfea8b

File tree

7 files changed

+50
-26
lines changed

7 files changed

+50
-26
lines changed

examples/capabilities/ReadMe.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<h3><img src="https://seleniumbase.github.io/img/green_logo.png" title="SeleniumBase" width="32" /> Using Desired Capabilities</h3>
44

5-
You can specify browser capabilities when running SeleniumBase tests on a remote Selenium Grid server such as <a href="https://www.browserstack.com/automate/capabilities" target="_blank">BrowserStack</a>, <a href="https://wiki.saucelabs.com/display/DOCS/Platform+Configurator#/" target="_blank">Sauce Labs</a>, or another.
5+
You can specify browser capabilities when running SeleniumBase tests on a remote Selenium Grid server such as <a href="https://www.browserstack.com/automate/capabilities" target="_blank">BrowserStack</a>, <a href="https://saucelabs.com/products/platform-configurator" target="_blank">Sauce Labs</a>, or another.
66

77
Sample run commands may look like this when run from the [SeleniumBase/examples/](https://github.com/seleniumbase/SeleniumBase/tree/master/examples) folder: (The browser is now specified in the capabilities file.)
88

@@ -47,7 +47,7 @@ capabilities = {
4747

4848
<ul>
4949
<li><a href="https://www.browserstack.com/automate/capabilities" target="_blank">BrowserStack desired capabilities</a></li>
50-
<li><a href="https://wiki.saucelabs.com/display/DOCS/Platform+Configurator#/" target="_blank">Sauce Labs desired capabilities</a></li>
50+
<li><a href="https://saucelabs.com/products/platform-configurator" target="_blank">Sauce Labs desired capabilities</a></li>
5151
</ul>
5252

5353
<div><b>Parsing desired capabilities:</b></div>

examples/capabilities/sample_cap_file_SL.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Desired capabilities example file for Sauce Labs
2-
# Generate from https://wiki.saucelabs.com/display/DOCS/Platform+Configurator#/
2+
# Generate from https://saucelabs.com/products/platform-configurator
33
capabilities = {
44
"browserName": "chrome",
55
"browserVersion": "latest",

help_docs/customizing_test_runs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ pytest --settings-file=custom_settings.py
452452

453453
<h3><img src="https://seleniumbase.github.io/img/green_logo.png" title="SeleniumBase" width="32" /> Running tests on a remote Selenium Grid:</h3>
454454

455-
🌐 SeleniumBase lets you run tests on remote Selenium Grids such as [BrowserStack](https://www.browserstack.com/automate#)'s Selenium Grid, [Sauce Labs](https://saucelabs.com/products/open-source-frameworks/selenium)'s Selenium Grid, other Grids, and even your own Grid:
455+
🌐 SeleniumBase lets you run tests on remote Selenium Grids such as [BrowserStack](https://www.browserstack.com/automate#)'s Selenium Grid, [Sauce Labs](https://saucelabs.com/products/platform-configurator)'s Selenium Grid, other Grids, and even your own Grid:
456456

457457
🌐 For setting browser desired capabilities while running Selenium remotely, see the ReadMe located here: https://github.com/seleniumbase/SeleniumBase/tree/master/examples/capabilities
458458

help_docs/desired_capabilities.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## [<img src="https://seleniumbase.github.io/img/logo6.png" title="SeleniumBase" width="32">](https://github.com/seleniumbase/SeleniumBase/) Using Desired Capabilities
44

5-
You can specify browser capabilities when running SeleniumBase tests on a remote Selenium Grid server such as <a href="https://www.browserstack.com/automate/capabilities" target="_blank">BrowserStack</a> or <a href="https://wiki.saucelabs.com/display/DOCS/Platform+Configurator#/" target="_blank">Sauce Labs</a>.
5+
You can specify browser capabilities when running SeleniumBase tests on a remote Selenium Grid server such as <a href="https://www.browserstack.com/automate/capabilities" target="_blank">BrowserStack</a> or <a href="https://saucelabs.com/products/platform-configurator" target="_blank">Sauce Labs</a>.
66

77
Sample run commands may look like this when run from the [SeleniumBase/examples/](https://github.com/seleniumbase/SeleniumBase/tree/master/examples) folder: (The browser is now specified in the capabilities file.)
88

@@ -47,7 +47,7 @@ capabilities = {
4747

4848
<ul>
4949
<li><a href="https://www.browserstack.com/automate/capabilities" target="_blank">BrowserStack desired capabilities</a></li>
50-
<li><a href="https://wiki.saucelabs.com/display/DOCS/Platform+Configurator#/" target="_blank">Sauce Labs desired capabilities</a></li>
50+
<li><a href="https://saucelabs.com/products/platform-configurator" target="_blank">Sauce Labs desired capabilities</a></li>
5151
</ul>
5252

5353
<div><b>Parsing desired capabilities:</b></div>

help_docs/how_it_works.md

Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44

55
<a id="how_seleniumbase_works"></a>
66

7-
👁️🔎 At the core, SeleniumBase works by extending [pytest](https://docs.pytest.org/en/latest/) as a direct plugin. SeleniumBase automatically spins up web browsers for tests (using [Selenium WebDriver](https://www.selenium.dev/documentation/webdriver/)), and then gives those tests access to the SeleniumBase libraries through the [BaseCase class](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/fixtures/base_case.py). Tests are also given access to [SeleniumBase command-line options](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/customizing_test_runs.md) and [SeleniumBase methods](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/method_summary.md), which provide additional functionality.
7+
👁️🔎 The primary [SeleniumBase syntax format](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/syntax_formats.md) works by extending [pytest](https://docs.pytest.org/en/latest/) as a direct plugin. SeleniumBase automatically spins up web browsers for tests (using [Selenium WebDriver](https://www.selenium.dev/documentation/webdriver/)), and then gives those tests access to the SeleniumBase libraries through the [BaseCase class](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/fixtures/base_case.py). Tests are also given access to [SeleniumBase command-line options](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/customizing_test_runs.md) and [SeleniumBase methods](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/method_summary.md), which provide additional functionality.
88

99
👁️🔎 ``pytest`` uses a feature called test discovery to automatically find and run Python methods that start with ``test_`` when those methods are located in Python files that start with ``test_`` or end with ``_test.py``.
1010

11-
👁️🔎 The most common way of using **SeleniumBase** is by importing ``BaseCase``:
11+
👁️🔎 The primary [SeleniumBase syntax format](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/syntax_formats.md) starts by importing ``BaseCase``:
1212

1313
```python
1414
from seleniumbase import BaseCase
1515
```
1616

17-
👁️🔎 This line activates ``pytest`` when a file is called directly with ``python``:
17+
👁️🔎 This next line activates ``pytest`` when a file is called directly with ``python`` by accident:
1818

1919
```python
2020
BaseCase.main(__name__, __file__)
@@ -29,12 +29,16 @@ class MyTestClass(BaseCase):
2929
👁️🔎 Test methods inside ``BaseCase`` classes become SeleniumBase tests: (These tests automatically launch a web browser before starting, and quit the web browser after ending. Default settings can be changed via command-line options.)
3030

3131
```python
32+
class MyTestClass(BaseCase):
3233
def test_abc(self):
34+
# ...
3335
```
3436

35-
👁️🔎 SeleniumBase APIs can be called from tests via ``self``:
37+
👁️🔎 [SeleniumBase APIs](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/method_summary.md) can be called from tests via ``self``:
3638

3739
```python
40+
class MyTestClass(BaseCase):
41+
def test_abc(self):
3842
self.open("https://example.com")
3943
```
4044

@@ -44,22 +48,20 @@ class MyTestClass(BaseCase):
4448
from seleniumbase import BaseCase
4549
BaseCase.main(__name__, __file__)
4650

47-
class TestMFALogin(BaseCase):
48-
def test_mfa_login(self):
49-
self.open("https://seleniumbase.io/realworld/login")
51+
class TestSimpleLogin(BaseCase):
52+
def test_simple_login(self):
53+
self.open("https://seleniumbase.io/simple/login")
5054
self.type("#username", "demo_user")
5155
self.type("#password", "secret_pass")
52-
self.enter_mfa_code("#totpcode", "GAXG2MTEOR3DMMDG") # 6-digit
53-
self.assert_text("Welcome!", "h1")
54-
self.highlight("img#image1") # A fancier assert_element() call
55-
self.click('a:contains("This Page")') # Use :contains() on any tag
56-
self.save_screenshot_to_logs() # ("./latest_logs" folder for test)
57-
self.click_link("Sign out") # Link must be "a" tag. Not "button".
58-
self.assert_element('a:contains("Sign in")')
59-
self.assert_exact_text("You have been signed out!", "#top_message")
56+
self.click('a:contains("Sign in")')
57+
self.assert_exact_text("Welcome!", "h1")
58+
self.assert_element("img#image1")
59+
self.highlight("#image1")
60+
self.click_link("Sign out")
61+
self.assert_text("signed out", "#top_message")
6062
```
6163

62-
(See the example, [test_mfa_login.py](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_mfa_login.py), for reference.)
64+
(See the example, [test_simple_login.py](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_simple_login.py), for reference.)
6365

6466
👁️🔎 Here are some examples of running tests with ``pytest``:
6567

@@ -71,7 +73,29 @@ pytest -k agent
7173
pytest offline_examples/
7274
```
7375

74-
(See <a href="https://seleniumbase.io/help_docs/syntax_formats/">Syntax_Formats</a> for more ways of structuring <b>SeleniumBase</b> tests.)
76+
👁️🔎 Here's a [SeleniumBase syntax format](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/syntax_formats.md) that uses the raw `driver`. Unlike the format mentioned earlier, it can be run with `python` instead of `pytest`. The `driver` includes original `driver` methods and new ones added by SeleniumBase:
77+
78+
```python
79+
from seleniumbase import Driver
80+
81+
driver = Driver()
82+
try:
83+
driver.get("https://seleniumbase.io/simple/login")
84+
driver.type("#username", "demo_user")
85+
driver.type("#password", "secret_pass")
86+
driver.click('a:contains("Sign in")')
87+
driver.assert_exact_text("Welcome!", "h1")
88+
driver.assert_element("img#image1")
89+
driver.highlight("#image1")
90+
driver.click_link("Sign out")
91+
driver.assert_text("signed out", "#top_message")
92+
finally:
93+
driver.quit()
94+
```
95+
96+
(See the example, [raw_login_driver.py](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/raw_login_driver.py), for reference.)
97+
98+
👁️🔎 Note that regular SeleniumBase formats (ones that use `BaseCase`, the `SB` context manager, or the `sb` `pytest` fixture) have more methods than the improved `driver` format. The regular formats also have more features. Some features, (such as the [SeleniumBase dashboard](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/example_logs/ReadMe.md)), require a `pytest` format.
7599

76100
--------
77101

seleniumbase/core/browser_launcher.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -584,8 +584,8 @@ def _add_chrome_proxy_extension(
584584
zip_it=True,
585585
multi_proxy=False,
586586
):
587-
"""Implementation of https://stackoverflow.com/a/35293284 for
588-
https://stackoverflow.com/questions/12848327/
587+
"""Implementation of https://stackoverflow.com/a/35293284/7058266
588+
for https://stackoverflow.com/q/12848327/7058266
589589
(Run Selenium on a proxy server that requires authentication.)"""
590590
args = " ".join(sys.argv)
591591
bypass_list = proxy_bypass_list

seleniumbase/utilities/selenium_grid/ReadMe.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ You can also run your tests on someone else's Selenium Grid to avoid managing yo
5858
pytest test_demo_site.py --server=USERNAME:KEY@hub.browserstack.com --port=80
5959
```
6060

61-
* [Sauce Labs](https://saucelabs.com/products/open-source-frameworks/selenium) Selenium Grid:
61+
* [Sauce Labs](https://saucelabs.com/products/platform-configurator) Selenium Grid:
6262

6363
```bash
6464
pytest test_demo_site.py --server=USERNAME:KEY@ondemand.us-east-1.saucelabs.com --port=443 --protocol=https

0 commit comments

Comments
 (0)