Skip to content

Commit 1d1ef32

Browse files
committed
Update the docs
1 parent e771226 commit 1d1ef32

File tree

5 files changed

+104
-13
lines changed

5 files changed

+104
-13
lines changed

examples/capabilities/ReadMe.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
### Using Desired Capabilities
1+
### <img src="https://seleniumbase.io/img/sb_icon.png" title="SeleniumBase" height="30" /> Using Desired Capabilities
22

33
You can specify browser desired capabilities for webdriver when running SeleniumBase tests on a remote SeleniumGrid server such as [BrowserStack](https://www.browserstack.com/automate/capabilities), [Sauce Labs](https://wiki.saucelabs.com/display/DOCS/Platform+Configurator#/), or [TestingBot](https://testingbot.com/support/other/test-options).
44

help_docs/ReadMe.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
<div><a href="https://seleniumbase.io/help_docs/translations/"><b>Language Translations</b></a></div>
1919
<div><a href="https://seleniumbase.io/examples/tour_examples/ReadMe/"><b>Tour Examples</b></a></div>
2020
<div><a href="https://seleniumbase.io/help_docs/mysql_installation/"><b>MySQL Installation Overview</b></a></div>
21+
<div><a href="https://seleniumbase.io/seleniumbase/utilities/selenium_grid/ReadMe/"><b>Using the Selenium Grid</b></a></div>
22+
<div><a href="https://seleniumbase.io/help_docs/desired_capabilities/"><b>Browser Desired Capabilities</b></a></div>
2123
<div><a href="https://seleniumbase.io/help_docs/using_safari_driver/"><b>Safari Driver Detailed Info</b></a></div>
2224
<div><a href="https://seleniumbase.io/help_docs/hidden_files_info/"><b>Seeing Hidden Files on macOS</b></a></div>
2325
<div><a href="https://seleniumbase.io/help_docs/happy_customers/"><b>SeleniumBase Case Studies</b></a></div>
@@ -40,6 +42,8 @@
4042
<div><a href="https://seleniumbase.com/help_docs/translations.html"><b>Language Translations</b></a></div>
4143
<div><a href="https://seleniumbase.com/examples/tour_examples/"><b>Tour Examples</b></a></div>
4244
<div><a href="https://seleniumbase.com/help_docs/mysql_installation.html"><b>MySQL Installation Overview</b></a></div>
45+
<div><a href="https://seleniumbase.com/seleniumbase/utilities/selenium_grid/"><b>Using the Selenium Grid</b></a></div>
46+
<div><a href="https://seleniumbase.com/help_docs/desired_capabilities.html"><b>Browser Desired Capabilities</b></a></div>
4347
<div><a href="https://seleniumbase.com/help_docs/using_safari_driver.html"><b>Safari Driver Detailed Info</b></a></div>
4448
<div><a href="https://seleniumbase.com/help_docs/hidden_files_info.html"><b>Seeing Hidden Files on macOS</b></a></div>
4549
<div><a href="https://seleniumbase.com/help_docs/happy_customers.html"><b>SeleniumBase Case Studies</b></a></div>

help_docs/desired_capabilities.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
### <img src="https://seleniumbase.io/img/sb_icon.png" title="SeleniumBase" height="30" /> Using Desired Capabilities
2+
3+
You can specify browser desired capabilities for webdriver when running SeleniumBase tests on a remote SeleniumGrid server such as [BrowserStack](https://www.browserstack.com/automate/capabilities), [Sauce Labs](https://wiki.saucelabs.com/display/DOCS/Platform+Configurator#/), or [TestingBot](https://testingbot.com/support/other/test-options).
4+
5+
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.)
6+
7+
```bash
8+
pytest my_first_test.py --browser=remote --server=USERNAME:KEY@hub.browserstack.com --port=80 --cap_file=capabilities/sample_cap_file_BS.py
9+
```
10+
11+
```bash
12+
pytest my_first_test.py --browser=remote --server=USERNAME:KEY@ondemand.saucelabs.com --port=80 --cap_file=capabilities/sample_cap_file_SL.py
13+
```
14+
15+
(Parameters: ``--browser=remote``, ``--server=SERVER``, ``--port=PORT``, and ``--cap_file=CAP_FILE.py``)
16+
17+
Here's an example desired capabilities file for BrowserStack:
18+
```python
19+
desired_cap = {
20+
'os': 'OS X',
21+
'os_version': 'High Sierra',
22+
'browser': 'Chrome',
23+
'browser_version': '77.0',
24+
'browserstack.local': 'false',
25+
'browserstack.selenium_version': '3.141.59'
26+
}
27+
```
28+
29+
Here's an example desired capabilities file for Sauce Labs:
30+
```python
31+
capabilities = {
32+
'browserName': 'firefox',
33+
'browserVersion': '70.0',
34+
'platformName': 'macOS 10.13',
35+
'sauce:options': {
36+
}
37+
}
38+
```
39+
40+
(You'll notice that the browser is now being specified in the capabilities file, rather than with ``--browser=BROWSER``)
41+
42+
You can generate desired capabilities for [BrowserStack](https://www.browserstack.com/automate/capabilities), [Sauce Labs](https://wiki.saucelabs.com/display/DOCS/Platform+Configurator#/), and [TestingBot](https://testingbot.com/support/other/test-options) by following those links to their respective websites.
43+
44+
A regex parser was built into SeleniumBase to capture all lines from the specified desired capabilities file in the following formats:
45+
``'KEY': 'VALUE'``
46+
``'KEY': True``
47+
``'KEY': False``
48+
``caps['KEY'] = "VALUE"``
49+
``caps['KEY'] = True``
50+
``caps['KEY'] = False``
51+
(Each pair must be on a separate line. You can interchange single and double quotes.)
52+
53+
You can also swap ``--browser=remote`` with an actual browser, eg ``--browser=chrome``, which will combine the default SeleniumBase desired capabilities with those that were specified in the capabilities file when using ``--cap_file=FILE.py``. Capabilities will override other parameters, so if you set the browser to one thing and the capabilities browser to another, SeleniumBase will use the capabilities browser as the browser.
54+
55+
You'll need default SeleniumBase capabilities for:
56+
* Using a proxy server (not the same as a Selenium Grid server)
57+
* Downloading files to a desired folder
58+
* Disabling some warnings on Chrome
59+
* Overriding a website's Content Security Policy on Chrome
60+
* Other possible reasons
61+
62+
You can also set browser desired capabilities from a command line string:
63+
Example:
64+
```bash
65+
pytest test_swag_labs.py --cap-string='{"browserName":"chrome","name":"test1"}' --server="127.0.0.1" --browser=remote
66+
```
67+
(Enclose cap-string in single quotes. Enclose parameter keys in double quotes.)
68+
69+
If you pass ``"*"`` into the ``"name"`` field of ``--cap-string``, the name will become the test identifier. Example:
70+
```bash
71+
pytest test_swag_labs.py --cap-string='{"browserName":"chrome","name":"*"}' --server="127.0.0.1" --browser=chrome
72+
```
73+
Example name: ``"my_first_test.MyTestClass.test_basic"``
74+
75+
### Using a local Selenium Grid
76+
77+
If using a local Selenium Grid with SeleniumBase, start up the Grid Hub and nodes first:
78+
```bash
79+
seleniumbase grid-hub start
80+
seleniumbase grid-node start
81+
```
82+
(The Selenium Server JAR file will be automatically downloaded for first-time Grid users. You'll also need Java installed to start up the Grid.)

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ nav:
7575
- Table of Contents: help_docs/ReadMe.md
7676
- Master QA: seleniumbase/masterqa/ReadMe.md
7777
- Decorators & Security: seleniumbase/common/ReadMe.md
78+
- Desired Capabilities: help_docs/desired_capabilities.md
7879
- Using Safari Driver: help_docs/using_safari_driver.md
7980
- macOS Hidden Files: help_docs/hidden_files_info.md
8081
- Case Studies: help_docs/happy_customers.md

seleniumbase/utilities/selenium_grid/ReadMe.md

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,48 +9,52 @@ The Selenium Grid Hub lets you distribute tests to run in parallel across multip
99
The following commands will work once you've installed seleniumbase.
1010

1111
#### <img src="https://seleniumbase.io/img/sb_icon.png" title="SeleniumBase" height="30" /> Downloading the Selenium Server JAR file:
12-
```
12+
```bash
1313
seleniumbase download server
1414
```
1515
* (Required for using your own Selenium Grid)
1616

1717
#### <img src="https://seleniumbase.io/img/sb_icon.png" title="SeleniumBase" height="30" /> Grid Hub server controls:
18-
```
18+
```bash
1919
seleniumbase grid-hub {start|stop} [OPTIONS]
2020
```
21-
Options:
22-
* ``-v``, ``--verbose`` (Increases verbosity of logging output.)
21+
<b>Options:</b>
22+
<ul>
23+
<li> -v / --verbose (Increases verbosity of logging output.)</li>
24+
</ul>
2325

2426
#### <img src="https://seleniumbase.io/img/sb_icon.png" title="SeleniumBase" height="30" /> Grid node server controls:
25-
```
27+
```bash
2628
seleniumbase grid-node {start|stop} --hub=[HUB_IP] [OPTIONS]
2729
```
28-
Options:
29-
* ``-v``, ``--verbose`` (Increases verbosity of logging output.)
30-
* ``--hub=[HUB_IP]`` (Specifies the Grid Hub to connect to. Default: "127.0.0.1".)
30+
<b>Options:</b>
31+
<ul>
32+
<li> -v / --verbose (Increases verbosity of logging output.)</li>
33+
<li> --hub=[HUB_IP] (Specifies the Grid Hub to connect to. Default: "127.0.0.1".)</li>
34+
</ul>
3135

3236
When the Grid Hub Console is up and running, you'll be able to find it here: [http://127.0.0.1:4444/grid/console](http://127.0.0.1:4444/grid/console)
3337

3438
Now you can run your tests on the Selenium Grid:
3539

36-
```
40+
```bash
3741
pytest test_suite.py --server=IP_ADDRESS --port=4444
3842
```
3943

4044
You can also run your tests on someone else's Selenium Grid to avoid managing your own. Here are some Selenium Grids that you can use (and the run command format):
4145

4246
* [BrowserStack](https://www.browserstack.com/automate#) Selenium Grid:
43-
```
47+
```bash
4448
pytest my_first_test.py --server=USERNAME:KEY@hub.browserstack.com --port=80
4549
```
4650

4751
* [Sauce Labs](https://saucelabs.com/products/open-source-frameworks/selenium) Selenium Grid:
48-
```
52+
```bash
4953
pytest my_first_test.py --server=USERNAME:KEY@ondemand.saucelabs.com --port=80
5054
```
5155

5256
* [TestingBot](https://testingbot.com/features) Selenium Grid:
53-
```
57+
```bash
5458
pytest my_first_test.py --server=USERNAME:KEY@hub.testingbot.com --port=80
5559
```
5660

0 commit comments

Comments
 (0)