The Selenium Grid Hub lets you distribute tests to run in parallel across multiple node machines. Each node machine can then run its own allocation of tests. This allows you to run a large suite of tests very quickly.
The following commands will work once you've installed seleniumbase.
seleniumbase download server
- (Required for using your own Selenium Grid)
seleniumbase grid-hub {start|stop|restart} [OPTIONS]
Options:
- -v / --verbose (Increases verbosity of logging output.)
- --timeout=TIMEOUT (Close idle browser after TIMEOUT sec.)
seleniumbase grid-node {start|stop|restart} --hub=[HUB_IP] [OPTIONS]
Options:
- -v / --verbose (Increases verbosity of logging output.)
- --hub=[HUB_IP] (Specifies the Grid Hub to connect to. Default: "127.0.0.1".)
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
Now you can run your tests on the Selenium Grid:
pytest test_demo_site.py --server=IP_ADDRESS --port=4444
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):
- BrowserStack Selenium Grid:
pytest test_demo_site.py --server=USERNAME:KEY@hub.browserstack.com --port=80
- Sauce Labs Selenium Grid:
pytest test_demo_site.py --server=USERNAME:KEY@ondemand.us-east-1.saucelabs.com --port=443 --protocol=https
To use a server on the https
protocol, add --protocol=https
:
(SeleniumBase 1.65.2 and newer uses https
automatically for --port=443
.)
pytest test_demo_site.py --protocol=https --server=IP_ADDRESS --port=PORT
(For setting browser desired capabilities while running Selenium remotely, see the desired capabilities documentation and the sample files located in SeleniumBase/examples/capabilities)