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
You can customize test runs from the command-line interface thanks to [SeleniumBase's pytest plugin](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/plugins/pytest_plugin.py), which adds CLI options for setting/enabling the browser type, headless mode, mobile mode, multithreading mode, demo mode, proxy config, user agent config, browser extensions, and more.
An easy way to override [seleniumbase/config/settings.py](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/config/settings.py) is by using a custom settings file.
162
162
Here's the command-line option to add to tests: (See [examples/custom_settings.py](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/custom_settings.py))
163
163
``--settings-file=custom_settings.py``
164
164
(Settings include default timeout values, a two-factor auth key, DB credentials, S3 credentials, and other important settings used by tests.)
165
165
166
-
### <imgsrc="https://seleniumbase.io/img/sb_icon.png"title="SeleniumBase"width="30" /> Running tests on a remote Selenium Grid:
166
+
### <imgsrc="https://seleniumbase.io/img/logo3a.png"title="SeleniumBase"width="28" /> Running tests on a remote Selenium Grid:
167
167
168
168
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, [TestingBot](https://testingbot.com/features)'s Selenium Grid, other Grids, and even your own Grid:
Or you can create your own Selenium Grid for test distribution. ([See this ReadMe for details](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/utilities/selenium_grid/ReadMe.md))
198
198
199
-
### <imgsrc="https://seleniumbase.io/img/sb_icon.png"title="SeleniumBase"width="30" /> Example tests using Logging:
199
+
### <imgsrc="https://seleniumbase.io/img/logo3a.png"title="SeleniumBase"width="28" /> Example tests using Logging:
200
200
201
201
```bash
202
202
pytest test_suite.py --browser=chrome
203
203
```
204
204
205
205
(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 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.)
If any test is moving too fast for your eyes to see what's going on, you can run it in **Demo Mode** by adding ``--demo`` on the command line, which pauses the browser briefly between actions, highlights page elements being acted on, and lets you know what test assertions are happening in real time:
210
210
@@ -218,22 +218,22 @@ You can override the default wait time by either updating [settings.py](https://
218
218
pytest my_first_test.py --demo --demo-sleep=1.2
219
219
```
220
220
221
-
### <imgsrc="https://seleniumbase.io/img/sb_icon.png"title="SeleniumBase"width="30" /> Passing additional data to tests:
221
+
### <imgsrc="https://seleniumbase.io/img/logo3a.png"title="SeleniumBase"width="28" /> Passing additional data to tests:
222
222
223
223
If you want to pass additional data from the command line to your tests, you can use ``--data=STRING``. Now inside your tests, you can use ``self.data`` to access that.
To run Pytest multithreaded on multiple CPUs at the same time, add ``-n=NUM`` or ``-n NUM`` on the command line, where NUM is the number of CPUs you want to use.
You can use ``--reruns=NUM`` to retry failing tests that many times. Use ``--reruns-delay=SECONDS`` to wait that many seconds between retries. Example:
(NOTE: You can add ``--show_report`` to immediately display Nosetest reports after the test suite completes. Only use ``--show_report`` when running tests locally because it pauses the test run.)
273
273
274
-
### <imgsrc="https://seleniumbase.io/img/sb_icon.png"title="SeleniumBase"width="30" /> Using a Proxy Server:
274
+
### <imgsrc="https://seleniumbase.io/img/logo3a.png"title="SeleniumBase"width="28" /> Using a Proxy Server:
275
275
276
276
If you wish to use a proxy server for your browser tests (Chrome and Firefox only), you can add ``--proxy=IP_ADDRESS:PORT`` as an argument on the command line.
277
277
@@ -291,15 +291,15 @@ To make things easier, you can add your frequently-used proxies to PROXY_LIST in
291
291
pytest proxy_test.py --proxy=proxy1
292
292
```
293
293
294
-
### <imgsrc="https://seleniumbase.io/img/sb_icon.png"title="SeleniumBase"width="30" /> Changing the User-Agent:
294
+
### <imgsrc="https://seleniumbase.io/img/logo3a.png"title="SeleniumBase"width="28" /> Changing the User-Agent:
295
295
296
296
If you wish to change the User-Agent for your browser tests (Chrome and Firefox only), you can add ``--agent="USER-AGENT-STRING"`` as an argument on the command line.
### <imgsrc="https://seleniumbase.io/img/sb_icon.png"title="SeleniumBase"width="30" /> Mobile Device Testing:
302
+
### <imgsrc="https://seleniumbase.io/img/logo3a.png"title="SeleniumBase"width="28" /> Mobile Device Testing:
303
303
304
304
Use ``--mobile`` to quickly run your tests using Chrome's mobile device emulator with default values for device metrics (CSS Width, CSS Height, Pixel-Ratio) and a default value set for the user agent. To configure the mobile device metrics, use ``--metrics="CSS_Width,CSS_Height,Pixel_Ratio"`` to set those values. You'll also be able to set the user agent with ``--agent="USER-AGENT-STRING"`` (a default user agent will be used if not specified). To find real values for device metrics, [see this GitHub Gist](https://gist.github.com/sidferreira/3f5fad525e99b395d8bd882ee0fd9d00). For a list of available user agent strings, [check out this page](https://developers.whatismybrowser.com/useragents/explore/).
* <b>[fixtures](https://github.com/seleniumbase/SeleniumBase/tree/master/seleniumbase/fixtures):</b> Includes [base_case.py](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/fixtures/base_case.py), where SeleniumBase test methods are defined.
6
6
* <b>[core](https://github.com/seleniumbase/SeleniumBase/tree/master/seleniumbase/core):</b> Includes [browser_launcher.py](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/core/browser_launcher.py), which is used for spinning up browsers for tests.
SeleniumBase console scripts help you get things done more easily, such as installing web drivers, creating a test directory with necessary configuration files, converting old WebDriver unittest scripts into SeleniumBase code, translating tests into multiple languages, and using the Selenium Grid.
0 commit comments