SeleniumBase/README.md

961 lines
50 KiB
Markdown
Raw Normal View History

2020-10-22 21:37:35 +08:00
<meta property="og:site_name" content="SeleniumBase">
<meta property="og:title" content="SeleniumBase: Python Web Automation and E2E Testing" />
2020-09-24 00:52:42 +08:00
<meta property="og:description" content="Build fast, reliable, end-to-end tests." />
2020-10-10 01:34:18 +08:00
<meta property="og:keywords" content="Python, pytest, selenium, webdriver, test automation, testing, seleniumbase, test framework, RPA, reports, website tours, presentations">
2020-12-23 01:26:52 +08:00
<meta property="og:image" content="https://seleniumbase.io/cdn/img/mac_sb_logo_5.png" />
2020-12-18 14:27:39 +08:00
<link rel="icon" href="https://seleniumbase.io/img/logo6.png" />
2020-06-08 01:41:56 +08:00
2020-05-23 05:06:14 +08:00
<p align="center"><a href="https://github.com/seleniumbase/SeleniumBase/">
2021-01-22 08:39:17 +08:00
<img src="https://seleniumbase.io/img/sb_logo_10.png" alt="SeleniumBase" title="SeleniumBase" width="280" /></a></p>
2021-01-22 08:08:00 +08:00
<p align="center">
2021-02-01 04:25:41 +08:00
<b>Build fast, reliable, end-to-end tests.</b>
2021-01-22 08:08:00 +08:00
</p>
2020-11-18 08:22:12 +08:00
2020-05-23 05:06:14 +08:00
<!-- View on GitHub -->
2020-11-18 08:22:12 +08:00
<p align="center"><a href="https://github.com/seleniumbase/SeleniumBase/releases">
2020-05-22 11:07:22 +08:00
<img src="https://img.shields.io/github/v/release/seleniumbase/SeleniumBase.svg?color=2277EE" alt="Latest Release on GitHub" /></a> <a href="https://pypi.python.org/pypi/seleniumbase">
2021-01-27 15:18:51 +08:00
<img src="https://img.shields.io/pypi/v/seleniumbase.svg?color=22AAEE" alt="Latest Release on PyPI" /></a> <a href="https://github.com/seleniumbase/SeleniumBase/actions">
2021-01-22 08:08:00 +08:00
<img src="https://github.com/seleniumbase/SeleniumBase/workflows/CI%20build/badge.svg" alt="SeleniumBase GitHub Actions" /></a> <a href="https://dev.azure.com/seleniumbase/seleniumbase/_build/latest?definitionId=1&branchName=master"> <img src="https://dev.azure.com/seleniumbase/seleniumbase/_apis/build/status/seleniumbase.SeleniumBase?branchName=master" alt="SeleniumBase Azure Pipelines" /></a> <a href="https://gitter.im/seleniumbase/SeleniumBase">
<img src="https://badges.gitter.im/seleniumbase/SeleniumBase.svg" alt="SeleniumBase" /></a> <a href="https://github.com/seleniumbase/SeleniumBase/stargazers"><img src="https://img.shields.io/github/stars/seleniumbase/seleniumbase.svg?color=19A57B" title="Stargazers" /></a> <a href="https://seleniumbase.io">
2020-11-18 08:22:12 +08:00
<img src="https://img.shields.io/badge/docs-%20seleniumbase.io-22BBAA.svg" alt="SeleniumBase.io Docs" /></a></p>
2020-05-14 04:42:14 +08:00
2021-01-22 08:08:00 +08:00
<p>
SeleniumBase is a Python framework for web automation, end-to-end testing, and more.
Tests are run with "pytest". Browsers are controlled by WebDriver.
</p>
2020-05-14 04:42:14 +08:00
2020-05-14 04:06:06 +08:00
<p align="center">
2020-08-04 09:48:42 +08:00
<a href="#python_installation">🚀 Start</a> |
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/features_list.md">🗂️ Features</a> |
2020-09-24 00:52:42 +08:00
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/customizing_test_runs.md">🖥️ CLI</a> |
2021-01-22 08:08:00 +08:00
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/ReadMe.md">👨‍🏫 Examples</a> |
<a href="https://github.com/seleniumbase/SeleniumBase/tree/master/examples/boilerplates">♻️ Boilerplates</a> |
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/locale_codes.md">🗾 Locales</a> |
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/js_package_manager.md">🗄️ PkgManager</a>
2020-05-13 06:15:22 +08:00
<br />
2020-10-10 23:55:57 +08:00
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/method_summary.md">📗 API</a> |
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/example_logs/ReadMe.md">📊 Reports</a> |
2021-01-22 08:08:00 +08:00
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/console_scripts/ReadMe.md">💻 Scripts</a> |
2020-08-08 13:21:46 +08:00
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/mobile_testing.md">📱 Mobile</a> |
2021-01-22 08:08:00 +08:00
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/syntax_formats.md">🔡 Syntax Formats</a> |
2021-01-23 04:33:35 +08:00
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/utilities/selenium_grid/ReadMe.md">🌐 Grid Hub</a> |
2020-08-08 13:21:46 +08:00
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/utilities/selenium_ide/ReadMe.md">⏺️ Recorder</a>
2020-08-04 09:48:42 +08:00
<br />
2020-08-08 13:21:46 +08:00
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/integrations/github/workflows/ReadMe.md">🤖 CI</a> |
2020-10-10 23:55:57 +08:00
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/translations.md">🌏 Translate</a> |
2020-05-13 04:15:34 +08:00
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/tour_examples/ReadMe.md">🗺️ Tours</a> |
2021-01-22 08:08:00 +08:00
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/visual_testing/ReadMe.md">🖼️ VisualTest</a> |
2020-10-13 04:21:43 +08:00
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/presenter/ReadMe.md">📑 Presenter</a> |
2020-10-11 04:53:33 +08:00
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/chart_maker/ReadMe.md">📈 ChartMaker</a> |
2020-09-08 13:44:12 +08:00
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/master_qa/ReadMe.md">🛂 MasterQA</a>
2020-05-06 08:16:21 +08:00
</p>
2020-05-14 06:44:08 +08:00
2021-02-06 12:26:25 +08:00
✅ Get set up in minutes. Deploy anywhere.<br />
✅ Build Web-UI tests with a [complete API](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/method_summary.md).<br />
✅ Generate [test reports and dashboards](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/example_logs/ReadMe.md).<br />
2020-11-18 08:22:12 +08:00
2020-10-10 02:56:37 +08:00
--------
2021-02-06 22:38:27 +08:00
<p align="left">Example: <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/my_first_test.py">my_first_test.py</a> (<code>--demo</code> mode)</p>
2020-10-10 02:13:42 +08:00
```bash
2021-02-06 12:26:25 +08:00
pytest my_first_test.py --demo
2020-10-10 02:13:42 +08:00
```
2021-02-06 13:03:39 +08:00
<p align="left"><a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/my_first_test.py"><img src="https://seleniumbase.io/cdn/gif/my_first_test_4.gif" alt="SeleniumBase Demo Mode" title="SeleniumBase Demo Mode" /></a></p>
2020-10-10 02:13:42 +08:00
2020-01-25 00:04:13 +08:00
<a id="python_installation"></a>
2021-01-22 08:08:00 +08:00
<h2><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="32" /> Python Setup:</h2>
2018-08-19 15:53:31 +08:00
2020-12-23 00:05:23 +08:00
🔵 Add **[Python](https://www.python.org/downloads/)** and **[Git](https://git-scm.com/)** to your System PATH.
2020-08-18 23:47:25 +08:00
2020-12-23 00:05:23 +08:00
🔵 Create a **[Python virtual environment](https://seleniumbase.io/help_docs/virtualenv_instructions/)**.
2018-08-10 12:20:44 +08:00
2020-10-02 15:43:41 +08:00
<a id="install_seleniumbase"></a>
2021-01-22 08:08:00 +08:00
<h2><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="32" /> Install SeleniumBase:</h2>
2020-10-02 15:43:41 +08:00
2021-01-22 08:08:00 +08:00
🔵 You can install ``seleniumbase`` from [GitHub](https://github.com/seleniumbase/SeleniumBase):
2020-10-02 15:43:41 +08:00
2020-01-27 06:25:33 +08:00
```bash
2021-01-22 08:08:00 +08:00
git clone https://github.com/seleniumbase/SeleniumBase.git
cd SeleniumBase/
pip install . # Normal installation
pip install -e . # Editable install
2020-01-27 06:25:33 +08:00
```
2020-10-02 15:43:41 +08:00
2021-01-22 08:08:00 +08:00
> (When using a virtual env, the Editable install is faster.)
2020-01-27 06:25:33 +08:00
2021-01-22 08:08:00 +08:00
🔵 You can also install ``seleniumbase`` from [pypi](https://pypi.python.org/pypi/seleniumbase):
2020-10-02 15:43:41 +08:00
```bash
2021-01-22 08:08:00 +08:00
pip install seleniumbase
2020-10-02 15:43:41 +08:00
```
2021-01-22 08:08:00 +08:00
> (Add ``--upgrade`` OR ``-U`` to upgrade an installation.)
> (Add ``--force-reinstall`` to upgrade dependencies.)
> (Use ``pip3`` if multiple versions of Python are installed.)
2020-12-23 00:05:23 +08:00
🔵 Type ``seleniumbase`` or ``sbase`` to verify that SeleniumBase was installed successfully:
2020-10-03 01:25:12 +08:00
```bash
______ __ _ ____
/ ____/__ / /__ ____ (_)_ ______ ___ / _ \____ ________
\__ \/ _ \/ / _ \/ __ \/ / / / / __ `__ \/ /_) / __ \/ ___/ _ \
___/ / __/ / __/ / / / / /_/ / / / / / / /_) / (_/ /__ / __/
/____/\___/_/\___/_/ /_/_/\__,_/_/ /_/ /_/_____/\__,_/____/\___/
2020-10-09 12:54:22 +08:00
-----------------------------------------------------------------
2020-10-03 01:25:12 +08:00
* USAGE: "seleniumbase [COMMAND] [PARAMETERS]"
* OR: "sbase [COMMAND] [PARAMETERS]"
COMMANDS:
install [DRIVER] [OPTIONS]
methods (List common Python methods)
2020-10-03 01:25:12 +08:00
options (List common pytest options)
2021-01-30 05:20:21 +08:00
mkdir [DIRECTORY] [OPTIONS]
mkfile [FILE.py] [OPTIONS]
mkpres [FILE.py] [LANG]
2020-10-03 01:25:12 +08:00
print [FILE] [OPTIONS]
translate [SB_FILE.py] [LANG] [ACTION]
convert [WEBDRIVER_UNITTEST_FILE.py]
extract-objects [SB_FILE.py]
inject-objects [SB_FILE.py] [OPTIONS]
objectify [SB_FILE.py] [OPTIONS]
2021-01-30 05:20:21 +08:00
revert-objects [SB_FILE.py] [OPTIONS]
2020-10-03 01:25:12 +08:00
encrypt (OR: obfuscate)
decrypt (OR: unobfuscate)
2021-01-30 05:20:21 +08:00
download server (The Selenium Grid JAR file)
2020-10-03 01:25:12 +08:00
grid-hub [start|stop] [OPTIONS]
grid-node [start|stop] --hub=[HOST/IP]
* (EXAMPLE: "sbase install chromedriver latest") *
Type "sbase help [COMMAND]" for specific command info.
For info on all commands, type: "seleniumbase --help".
* (Use "pytest" for running tests) *
```
2020-12-18 14:27:39 +08:00
<h3><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="32" /> Download a webdriver:</h3>
2019-04-14 17:05:21 +08:00
2020-12-23 00:05:23 +08:00
✅ SeleniumBase can download webdrivers to the [seleniumbase/drivers](https://github.com/seleniumbase/SeleniumBase/tree/master/seleniumbase/drivers) folder with the ``install`` command:
2020-10-03 01:25:12 +08:00
2019-08-17 14:47:52 +08:00
```bash
2020-10-02 15:43:41 +08:00
sbase install chromedriver
2019-04-14 17:05:21 +08:00
```
2020-10-03 01:25:12 +08:00
* You need a different webdriver for each browser to automate: ``chromedriver`` for Chrome, ``edgedriver`` for Edge, ``geckodriver`` for Firefox, and ``operadriver`` for Opera.
* If you have the latest version of Chrome installed, get the latest chromedriver (<i>otherwise it defaults to chromedriver 2.44 for compatibility reasons</i>):
2020-10-03 01:25:12 +08:00
```bash
2020-10-02 15:43:41 +08:00
sbase install chromedriver latest
```
2018-12-29 01:08:57 +08:00
2020-10-03 01:25:12 +08:00
* If you run a test without the correct webdriver installed, the driver will be downloaded automatically.
2020-10-02 15:43:41 +08:00
(See [seleniumbase.io/seleniumbase/console_scripts/ReadMe/](https://seleniumbase.io/seleniumbase/console_scripts/ReadMe/) for more information on SeleniumBase console scripts.)
2020-07-23 10:54:57 +08:00
2021-01-29 11:28:00 +08:00
<h3><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="32" /> Running tests:</h3>
2020-10-02 15:43:41 +08:00
2021-01-29 11:28:00 +08:00
🔵 <b>If you've cloned SeleniumBase from GitHub, you can run sample tests from the [examples/](https://github.com/seleniumbase/SeleniumBase/tree/master/examples) folder:</b>
2020-10-02 15:43:41 +08:00
```bash
2021-01-29 11:28:00 +08:00
cd examples/
2020-10-02 15:43:41 +08:00
pytest test_demo_site.py
2018-08-08 10:25:36 +08:00
```
2020-08-08 13:21:46 +08:00
2021-01-29 11:28:00 +08:00
> (Chrome is the default browser if not specified with ``--browser=BROWSER``. On Linux, ``--headless`` is the default behavior. You can also run in headless mode on any OS. If your Linux machine has a GUI and you want to see the web browser as tests run, add ``--headed`` or ``--gui``.)
2018-10-20 03:44:16 +08:00
2020-11-12 14:40:29 +08:00
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_demo_site.py"><img src="https://seleniumbase.io/cdn/gif/demo_page_1.gif" title="SeleniumBase Demo Page" /></a><br />
2021-01-29 11:28:00 +08:00
🔵 <b>Here are more examples that you can run:</b>
2020-10-02 15:43:41 +08:00
```bash
pytest my_first_test.py
2021-01-29 11:28:00 +08:00
2020-10-02 15:43:41 +08:00
pytest test_swag_labs.py
```
2020-12-23 00:05:23 +08:00
🔵 <b>Run [my_first_test.py](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/my_first_test.py) in Demo Mode:</b>
2020-05-20 14:01:43 +08:00
```bash
pytest my_first_test.py --demo
```
2021-02-06 13:03:39 +08:00
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/my_first_test.py"><img src="https://seleniumbase.io/cdn/gif/my_first_test_4.gif" alt="SeleniumBase Demo Mode" title="SeleniumBase Demo Mode" /></a>
2020-05-20 14:01:43 +08:00
<b>Here's the code for [my_first_test.py](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/my_first_test.py):</b>
2020-05-06 08:16:21 +08:00
```python
from seleniumbase import BaseCase
class MyTestClass(BaseCase):
2021-01-26 03:40:13 +08:00
def test_basics(self):
url = "https://store.xkcd.com/collections/posters"
self.open(url)
2020-08-25 03:55:24 +08:00
self.type('input[name="q"]', "xkcd book")
self.click('input[value="Search"]')
2020-06-14 13:17:37 +08:00
self.assert_text("xkcd: volume 0", "h3")
2020-05-06 08:16:21 +08:00
self.open("https://xkcd.com/353/")
self.assert_title("xkcd: Python")
self.assert_element('img[alt="Python"]')
self.click('a[rel="license"]')
self.assert_text("free to copy and reuse")
self.go_back()
2021-01-26 03:40:13 +08:00
self.click_link("About")
2020-06-14 13:17:37 +08:00
self.assert_exact_text("xkcd.com", "h2")
2020-05-06 08:16:21 +08:00
```
2020-01-27 06:25:33 +08:00
* By default, **[CSS Selectors](https://www.w3schools.com/cssref/css_selectors.asp)** are used for finding page elements.
* If you're new to CSS Selectors, games like [Flukeout](http://flukeout.github.io/) can help you learn.
* Here are some common ``SeleniumBase`` methods you might find in tests:
2020-05-23 13:25:36 +08:00
2019-08-18 05:03:33 +08:00
```python
self.open(URL) # Navigate to the web page
self.click(SELECTOR) # Click a page element
2020-06-14 13:17:37 +08:00
self.type(SELECTOR, TEXT) # Type text (Add "\n" to text for pressing enter/return.)
2019-08-18 05:23:40 +08:00
self.assert_element(SELECTOR) # Assert element is visible
self.assert_text(TEXT) # Assert text is visible (has optional SELECTOR arg)
2019-08-18 05:03:33 +08:00
self.assert_title(PAGE_TITLE) # Assert page title
self.assert_no_404_errors() # Assert no 404 errors from files on the page
2019-08-18 05:23:40 +08:00
self.assert_no_js_errors() # Assert no JavaScript errors on the page (Chrome-ONLY)
2020-10-09 12:54:22 +08:00
self.execute_script(JAVASCRIPT) # Execute JavaScript code
2019-08-18 05:03:33 +08:00
self.go_back() # Navigate to the previous URL
self.get_text(SELECTOR) # Get text from a selector
self.get_attribute(SELECTOR, ATTRIBUTE) # Get a specific attribute from a selector
self.is_element_visible(SELECTOR) # Determine if an element is visible on the page
self.is_text_visible(TEXT) # Determine if text is visible on the page (optional SELECTOR)
self.hover_and_click(HOVER_SELECTOR, CLICK_SELECTOR) # Mouseover element & click another
2019-08-18 05:03:33 +08:00
self.select_option_by_text(DROPDOWN_SELECTOR, OPTION_TEXT) # Select a dropdown option
self.switch_to_frame(FRAME_NAME) # Switch webdriver control to an iframe on the page
2019-08-18 05:23:40 +08:00
self.switch_to_default_content() # Switch webdriver control out of the current iframe
2019-08-18 05:03:33 +08:00
self.switch_to_window(WINDOW_NUMBER) # Switch to a different window/tab
self.save_screenshot(FILE_NAME) # Save a screenshot of the current page
```
2020-05-23 13:25:36 +08:00
2020-12-23 00:05:23 +08:00
🔵 For the complete list of SeleniumBase methods, see: <b><a href="https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/method_summary.md">Method Summary</a></b>
2018-08-08 10:25:36 +08:00
2020-12-18 14:27:39 +08:00
<h2><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="32" /> Learn More:</h2>
2018-03-10 06:42:33 +08:00
2020-12-23 00:05:23 +08:00
✅ Automatic WebDriver Abilities:
<p>SeleniumBase automatically handles common WebDriver actions such as spinning up web browsers and saving screenshots during test failures. (<i><a href="https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/customizing_test_runs.md">Read more about customizing test runs</a>.</i>)</p>
2018-03-08 17:14:53 +08:00
2020-12-23 00:05:23 +08:00
✅ Simplified Code:
<p>SeleniumBase uses simple syntax for commands. Example:</p>
2020-05-23 13:25:36 +08:00
2019-04-14 17:05:21 +08:00
```python
2020-06-14 13:17:37 +08:00
self.type("input", "dogs\n")
2019-04-14 17:05:21 +08:00
```
2020-05-23 13:25:36 +08:00
2020-12-23 00:05:23 +08:00
SeleniumBase tests can be run with both ``pytest`` and ``nosetests``, but using ``pytest`` is recommended. (``chrome`` is the default browser if not specified.)
2020-05-23 13:25:36 +08:00
2019-08-17 14:47:52 +08:00
```bash
2018-03-08 17:14:53 +08:00
pytest my_first_test.py --browser=chrome
2018-03-08 17:21:19 +08:00
2018-12-11 15:01:57 +08:00
nosetests test_suite.py --browser=firefox
2018-03-08 17:14:53 +08:00
```
2020-05-23 13:25:36 +08:00
2020-12-23 00:05:23 +08:00
✅ Automatic Test Discovery:
<p>All Python methods that start with <code>test_</code> will automatically be run when using <code>pytest</code> or <code>nosetests</code> on a Python file, (<i>or on folders containing Python files</i>). You can also be more specific on what to run within a file by using the following: (<i>Note that the syntax is different for pytest vs nosetests.</i>)</p>
2020-05-23 13:25:36 +08:00
2019-12-25 07:43:41 +08:00
```bash
2020-10-09 12:54:22 +08:00
pytest [FILE_NAME.py]::[CLASS_NAME]::[METHOD_NAME]
2020-12-23 00:05:23 +08:00
2020-10-09 12:54:22 +08:00
nosetests [FILE_NAME.py]:[CLASS_NAME].[METHOD_NAME]
2019-12-25 07:43:41 +08:00
```
2018-08-08 10:25:36 +08:00
2020-12-23 00:05:23 +08:00
✅ No More Flaky Tests:
<p>SeleniumBase methods automatically wait for page elements to finish loading before interacting with them (<i>up to a timeout limit</i>). This means you <b>no longer need</b> random <span><b>time.sleep()</b></span> statements in your scripts.</p>
2020-05-28 23:34:30 +08:00
<img src="https://img.shields.io/badge/Flaky Tests%3F-%20NO%21-11BBDD.svg" alt="NO MORE FLAKY TESTS!" />
2018-03-09 06:47:00 +08:00
2020-12-23 00:05:23 +08:00
✅ Automated/Manual Hybrid Mode:</h4>
2020-12-24 11:03:53 +08:00
<p>SeleniumBase includes a solution called <b><a href="https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/masterqa/ReadMe.md">MasterQA</a></b>, which speeds up manual testing by having automation perform all the browser actions while the manual tester handles validation.</p>
2017-10-31 10:45:09 +08:00
2020-12-23 00:05:23 +08:00
✅ Feature-Rich:
<p>For a full list of SeleniumBase features, <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/features_list.md">Click Here</a>.</p>
2019-04-14 17:05:21 +08:00
2015-12-05 05:11:53 +08:00
2020-01-24 15:26:07 +08:00
<a id="detailed_instructions"></a>
2021-01-22 08:08:00 +08:00
<img src="https://seleniumbase.io/cdn/img/mac_sb_logo_5.png" title="SeleniumBase" width="300">
2016-02-13 15:59:34 +08:00
2020-12-18 14:27:39 +08:00
<h2><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="32" /> Detailed Instructions:</h2>
2016-02-14 03:59:16 +08:00
2020-08-08 13:21:46 +08:00
<a id="seleniumbase_demo_mode"></a> <b>Use Demo Mode to help you see what tests are asserting.</b>
2019-04-15 15:38:50 +08:00
2020-12-23 00:05:23 +08:00
🔵 If the example test is moving too fast for your eyes, 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:
2020-05-23 13:25:36 +08:00
2019-08-17 14:47:52 +08:00
```bash
2019-10-22 14:14:33 +08:00
pytest my_first_test.py --demo
2016-01-17 07:33:14 +08:00
```
2020-12-23 00:05:23 +08:00
🔵 ``Pytest`` includes test discovery. If you don't specify a specific file or folder to run from, ``pytest`` will search all subdirectories automatically for tests to run based on the following matching criteria:
2019-08-18 05:03:33 +08:00
Python filenames that start with ``test_`` or end with ``_test.py``.
Python methods that start with ``test_``.
The Python class name can be anything since SeleniumBase's ``BaseCase`` class inherits from the ``unittest.TestCase`` class.
You can see which tests are getting discovered by ``pytest`` by using:
2020-05-23 13:25:36 +08:00
2019-08-18 05:03:33 +08:00
```bash
pytest --collect-only -q
```
2015-12-05 05:11:53 +08:00
2020-12-23 00:05:23 +08:00
🔵 You can use the following calls in your scripts to help you debug issues:
2020-08-08 13:21:46 +08:00
2015-12-05 05:11:53 +08:00
```python
import time; time.sleep(5) # Makes the test wait and do nothing for 5 seconds.
import ipdb; ipdb.set_trace() # Enter debugging mode. n = next, c = continue, s = step.
import pytest; pytest.set_trace() # Enter debugging mode. n = next, c = continue, s = step.
2015-12-05 05:11:53 +08:00
```
2020-12-23 00:05:23 +08:00
🔵 To pause an active test that throws an exception or error, add ``--pdb``:
2020-05-23 13:25:36 +08:00
2019-08-18 05:03:33 +08:00
```bash
2020-08-08 13:21:46 +08:00
pytest my_first_test.py --pdb
2015-12-05 05:11:53 +08:00
```
2020-05-23 13:25:36 +08:00
2019-08-18 05:03:33 +08:00
The code above will leave your browser window open in case there's a failure. (ipdb commands: 'n', 'c', 's' => next, continue, step).
2015-12-05 05:11:53 +08:00
2020-12-23 00:05:23 +08:00
🔵 Here are some useful command-line options that come with ``pytest``:
2020-05-23 13:25:36 +08:00
2019-08-17 14:47:52 +08:00
```bash
2020-08-11 11:57:38 +08:00
-v # Verbose mode. Prints the full name of each test run.
2020-08-08 13:21:46 +08:00
-q # Quiet mode. Print fewer details in the console output when running tests.
2019-08-17 14:47:52 +08:00
-x # Stop running the tests after the first failure is reached.
--html=report.html # Creates a detailed pytest-html report after tests finish.
2020-09-30 08:08:30 +08:00
--collect-only | --co # Show what tests would get run. (Without running them)
2019-08-18 05:03:33 +08:00
-n=NUM # Multithread the tests using that many threads. (Speed up test runs!)
2020-05-10 08:15:32 +08:00
-s # See print statements. (Should be on by default with pytest.ini present.)
--junit-xml=report.xml # Creates a junit-xml report after tests finish.
--pdb # If a test fails, pause run and enter debug mode. (Don't use with CI!)
2020-08-09 01:30:48 +08:00
-m=MARKER # Run tests with the specified pytest marker.
2018-08-11 01:38:34 +08:00
```
2019-08-17 14:47:52 +08:00
2020-12-23 00:05:23 +08:00
🔵 SeleniumBase provides additional ``pytest`` command-line options for tests:
2020-05-23 13:25:36 +08:00
2019-08-17 14:47:52 +08:00
```bash
2020-08-11 11:57:38 +08:00
--browser=BROWSER # (The web browser to use. Default: "chrome".)
2021-01-24 15:53:21 +08:00
--chrome # (Shortcut for "--browser=chrome". On by default.)
--edge # (Shortcut for "--browser=edge".)
--firefox # (Shortcut for "--browser=firefox".)
--opera # (Shortcut for "--browser=opera".)
--safari # (Shortcut for "--browser=safari".)
--cap-file=FILE # (The web browser's desired capabilities to use.)
2020-04-20 02:41:09 +08:00
--cap-string=STRING # (The web browser's desired capabilities to use.)
2020-08-08 13:21:46 +08:00
--settings-file=FILE # (Override default SeleniumBase settings.)
2019-08-18 05:03:33 +08:00
--env=ENV # (Set a test environment. Use "self.env" to use this in tests.)
2020-08-08 13:21:46 +08:00
--data=DATA # (Extra test data. Access with "self.data" in tests.)
--var1=DATA # (Extra test data. Access with "self.var1" in tests.)
--var2=DATA # (Extra test data. Access with "self.var2" in tests.)
--var3=DATA # (Extra test data. Access with "self.var3" in tests.)
--user-data-dir=DIR # (Set the Chrome user data directory to use.)
2020-08-11 11:57:38 +08:00
--server=SERVER # (The Selenium Grid server/IP used for tests.)
--port=PORT # (The Selenium Grid port used by the test server.)
--proxy=SERVER:PORT # (Connect to a proxy server:port for tests.)
--proxy=USERNAME:PASSWORD@SERVER:PORT # (Use authenticated proxy server.)
2020-08-08 13:21:46 +08:00
--agent=STRING # (Modify the web browser's User-Agent string.)
--mobile # (Use the mobile device emulator while running tests.)
2020-11-18 08:22:12 +08:00
--metrics=STRING # (Set mobile metrics: "CSSWidth,CSSHeight,PixelRatio".)
2020-08-18 04:28:28 +08:00
--extension-zip=ZIP # (Load a Chrome Extension .zip|.crx, comma-separated.)
--extension-dir=DIR # (Load a Chrome Extension directory, comma-separated.)
2020-08-08 13:21:46 +08:00
--headless # (Run tests headlessly. Default mode on Linux OS.)
--headed # (Run tests with a GUI on Linux OS.)
2020-08-20 14:34:44 +08:00
--locale=LOCALE_CODE # (Set the Language Locale Code for the web browser.)
--start-page=URL # (The starting URL for the web browser when tests begin.)
--archive-logs # (Archive old log files instead of deleting them.)
2020-10-12 21:46:06 +08:00
--time-limit=SECONDS # (Safely fail any test that exceeds the time limit.)
2020-08-08 13:21:46 +08:00
--slow # (Slow down the automation. Faster than using Demo Mode.)
--demo # (Slow down and visually see test actions as they occur.)
--demo-sleep=SECONDS # (Set the wait time after Demo Mode actions.)
2019-08-18 05:03:33 +08:00
--highlights=NUM # (Number of highlight animations for Demo Mode actions.)
--message-duration=SECONDS # (The time length for Messenger alerts.)
2020-08-08 13:21:46 +08:00
--check-js # (Check for JavaScript errors after page loads.)
--ad-block # (Block some types of display ads after page loads.)
--block-images # (Block images from loading during tests.)
--verify-delay=SECONDS # (The delay before MasterQA verification checks.)
2020-10-22 21:37:35 +08:00
--disable-csp # (Disable the Content Security Policy of websites.)
--disable-ws # (Disable Web Security on Chromium-based browsers.)
--enable-ws # (Enable Web Security on Chromium-based browsers.)
2020-08-08 13:21:46 +08:00
--enable-sync # (Enable "Chrome Sync".)
--use-auto-ext # (Use Chrome's automation extension.)
--remote-debug # (Enable Chrome's Remote Debugger on http://localhost:9222)
2020-12-21 05:47:30 +08:00
--dashboard # (Enable the SeleniumBase Dashboard. Saved at: dashboard.html)
2020-08-08 13:21:46 +08:00
--swiftshader # (Use Chrome's "--use-gl=swiftshader" feature.)
--incognito # (Enable Chrome's Incognito mode.)
--guest # (Enable Chrome's Guest mode.)
--devtools # (Open Chrome's DevTools when the browser opens.)
2021-02-06 12:26:25 +08:00
--reuse-session | --rs # (Reuse browser session between tests.)
2020-08-08 13:21:46 +08:00
--crumbs # (Delete all cookies between tests reusing a session.)
--maximize-window # (Start tests with the web browser window maximized.)
--save-screenshot # (Save a screenshot at the end of each test.)
--visual-baseline # (Set the visual baseline for Visual/Layout tests.)
--timeout-multiplier=MULTIPLIER # (Multiplies the default timeout values.)
2019-08-18 05:03:33 +08:00
```
2020-05-23 13:25:36 +08:00
2019-08-18 05:03:33 +08:00
(For more details, see the full list of command-line options **[here](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/plugins/pytest_plugin.py)**.)
2020-12-23 00:56:21 +08:00
🔵 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.
2020-05-23 13:25:36 +08:00
2019-08-17 14:47:52 +08:00
```bash
2017-04-25 12:17:26 +08:00
cd examples/
2016-05-21 12:05:15 +08:00
2018-12-11 15:01:57 +08:00
pytest test_suite.py --browser=chrome
2018-02-14 14:43:13 +08:00
2018-12-11 15:01:57 +08:00
pytest test_suite.py --browser=firefox
2015-12-05 05:11:53 +08:00
```
2017-04-25 12:17:26 +08:00
2019-08-18 05:03:33 +08:00
An easy way to override seleniumbase/config/settings.py is by using a custom settings file.
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))
``--settings_file=custom_settings.py``
2019-09-23 03:27:30 +08:00
(Settings include default timeout values, a two-factor auth key, DB credentials, S3 credentials, and other important settings used by tests.)
2018-02-14 14:43:13 +08:00
2020-12-23 00:56:21 +08:00
🔵 To pass additional data from the command-line to tests, add ``--data="ANY STRING"``.
2020-10-03 01:25:12 +08:00
Inside your tests, you can use ``self.data`` to access that.
2018-08-10 12:20:44 +08:00
2021-01-29 11:28:00 +08:00
<h3><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="32" /> Test Directory Configuration:</h3>
2018-08-10 12:20:44 +08:00
2021-01-29 11:28:00 +08:00
🔵 When running tests with **pytest**, you'll want a copy of **[pytest.ini](https://github.com/seleniumbase/SeleniumBase/blob/master/pytest.ini)** in your root folders. When running tests with **nosetests**, you'll want a copy of **[setup.cfg](https://github.com/seleniumbase/SeleniumBase/blob/master/setup.cfg)** in your root folders. These files specify default configuration details for tests. Folders should also include a blank ``__init__.py`` file, which allows your tests to import files from that folder.
2018-02-02 06:05:54 +08:00
2021-01-29 11:28:00 +08:00
🔵 ``sbase mkdir DIR`` creates a folder with config files and sample tests:
2020-05-23 13:25:36 +08:00
2019-08-17 14:47:52 +08:00
```bash
2020-10-02 15:43:41 +08:00
sbase mkdir ui_tests
2018-08-10 12:20:44 +08:00
```
2015-12-05 05:11:53 +08:00
2021-01-29 11:28:00 +08:00
> That new folder will have these files:
```bash
ui_tests/
├── __init__.py
├── boilerplates/
│ ├── __init__.py
│ ├── base_test_case.py
│ ├── boilerplate_test.py
│ ├── page_objects.py
│ └── samples/
│ ├── __init__.py
│ ├── google_objects.py
│ └── google_test.py
├── my_first_test.py
├── parameterized_test.py
├── pytest.ini
├── requirements.txt
├── setup.cfg
└── test_demo_site.py
```
<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:
```bash
sbase mkdir ui_tests --basic
```
> That new folder will have these files:
```bash
ui_tests/
├── __init__.py
├── pytest.ini
├── requirements.txt
└── setup.cfg
```
Of those files, the ``pytest.ini`` config file is the most important, followed by a blank ``__init__.py`` file. There's also a ``setup.cfg`` file (only needed for nosetests). Finally, the ``requirements.txt`` file can be used to help you install seleniumbase into your environments (if it's not already installed).
2020-12-23 00:05:23 +08:00
--------
2019-12-25 07:43:41 +08:00
2020-12-19 13:14:42 +08:00
<h3><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="32" /> Log files from failed tests:</h3>
2019-12-25 07:43:41 +08:00
Let's try an example of a test that fails:
2020-05-23 13:25:36 +08:00
2019-12-25 07:43:41 +08:00
```python
""" test_fail.py """
from seleniumbase import BaseCase
class MyTestClass(BaseCase):
def test_find_army_of_robots_on_xkcd_desert_island(self):
self.open("https://xkcd.com/731/")
self.assert_element("div#ARMY_OF_ROBOTS", timeout=1) # This should fail
```
2021-01-29 11:28:00 +08:00
You can run it from the ``examples/`` folder like this:
2020-05-23 13:25:36 +08:00
2019-12-25 07:43:41 +08:00
```bash
pytest test_fail.py
```
2020-12-23 00:56:21 +08:00
🔵 You'll notice that a logs folder, "latest_logs", was created to hold information about the failing test, and screenshots. During test runs, past results get moved to the archived_logs folder if you have ARCHIVE_EXISTING_LOGS set to True in [settings.py](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/config/settings.py), or if your run tests with ``--archive-logs``. If you choose not to archive existing logs, they will be deleted and replaced by the logs of the latest test run.
2019-12-25 07:43:41 +08:00
2020-12-18 14:27:39 +08:00
--------
2019-12-25 07:43:41 +08:00
2020-12-18 14:27:39 +08:00
<h3><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="32" /> The SeleniumBase Dashboard:</h3>
2020-12-23 00:56:21 +08:00
🔵 The ``--dashboard`` option for pytest generates a SeleniumBase Dashboard located at ``dashboard.html``, which updates automatically as tests run and produce results. Example:
2020-12-19 13:14:42 +08:00
```bash
pytest --dashboard --rs --headless
```
2020-12-18 14:27:39 +08:00
<img src="https://seleniumbase.io/cdn/img/dashboard_1.png" alt="The SeleniumBase Dashboard" title="The SeleniumBase Dashboard" width="360" />
2020-12-23 00:56:21 +08:00
🔵 Additionally, you can host your own SeleniumBase Dashboard Server on a port of your choice. Here's an example of that using Python 3's ``http.server``:
2020-12-18 14:27:39 +08:00
```bash
python -m http.server 1948
```
2020-12-23 00:56:21 +08:00
🔵 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 ``CTRL-C`` to stop the http server.)
2017-04-28 08:40:22 +08:00
2020-12-23 00:56:21 +08:00
🔵 Here's a full example of what the SeleniumBase Dashboard may look like:
2020-12-18 14:27:39 +08:00
```bash
pytest test_suite.py --dashboard --rs --headless
```
<img src="https://seleniumbase.io/cdn/img/dashboard_2.png" alt="The SeleniumBase Dashboard" title="The SeleniumBase Dashboard" width="480" />
--------
<a id="creating_visual_reports"></a>
2020-12-19 13:14:42 +08:00
<h3><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="32" /> Creating Visual Test Reports:</h3>
2017-04-28 08:40:22 +08:00
2020-05-22 11:39:59 +08:00
<h4><b>Pytest Reports:</b></h4>
2017-04-25 12:17:26 +08:00
2020-12-23 00:56:21 +08:00
🔵 Using ``--html=report.html`` gives you a fancy report of the name specified after your test suite completes.
2020-05-23 13:25:36 +08:00
2019-08-17 14:47:52 +08:00
```bash
2018-12-11 15:01:57 +08:00
pytest test_suite.py --html=report.html
2016-05-09 06:38:32 +08:00
```
2016-05-23 04:41:30 +08:00
2020-10-12 06:53:54 +08:00
<img src="https://seleniumbase.io/cdn/img/html_report.png" alt="Example Pytest Report" title="Example Pytest Report" width="520" />
2018-11-09 00:15:00 +08:00
2020-12-23 00:56:21 +08:00
🔵 When combining pytest html reports with SeleniumBase Dashboard usage, the pie chart from the Dashboard will get added to the html report. Additionally, if you set the html report URL to be the same as the Dashboard URL when also using the dashboard, (example: ``--dashboard --html=dashboard.html``), then the Dashboard will become an advanced html report when all the tests complete.
2020-12-19 13:14:42 +08:00
2020-12-23 00:56:21 +08:00
🔵 Here's an example of an upgraded html report:
2020-12-22 07:03:13 +08:00
```bash
pytest test_suite.py --dashboard --html=report.html
```
<img src="https://seleniumbase.io/cdn/img/dash_report.jpg" alt="Dashboard Pytest HTML Report" title="Dashboard Pytest HTML Report" width="520" />
2020-12-19 13:14:42 +08:00
If viewing pytest html reports in [Jenkins](https://www.jenkins.io/), you may need to [configure Jenkins settings](https://stackoverflow.com/a/46197356) for the html to render correctly. This is due to [Jenkins CSP changes](https://www.jenkins.io/doc/book/system-administration/security/configuring-content-security-policy/).
2019-07-22 02:14:40 +08:00
You can also use ``--junit-xml=report.xml`` to get an xml report instead. Jenkins can use this file to display better reporting for your tests.
2020-05-23 13:25:36 +08:00
2019-08-17 14:47:52 +08:00
```bash
2019-07-22 02:14:40 +08:00
pytest test_suite.py --junit-xml=report.xml
```
2020-05-22 11:39:59 +08:00
<h4><b>Nosetest Reports:</b></h4>
2017-04-28 08:40:22 +08:00
2018-03-05 06:55:00 +08:00
The ``--report`` option gives you a fancy report after your test suite completes.
2020-05-23 13:25:36 +08:00
2019-08-17 14:47:52 +08:00
```bash
2018-12-11 15:01:57 +08:00
nosetests test_suite.py --report
2017-04-28 08:40:22 +08:00
```
2020-05-23 13:25:36 +08:00
2020-11-12 13:57:20 +08:00
<img src="https://seleniumbase.io/cdn/img/nose_report.png" alt="Example Nosetest Report" title="Example Nosetest Report" width="320" />
2017-04-28 08:40:22 +08:00
2019-12-07 15:05:19 +08:00
(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.)
2015-12-05 05:11:53 +08:00
2020-07-23 10:54:57 +08:00
<h4><b>Allure Reports:</b></h4>
See: [https://docs.qameta.io/allure/](https://docs.qameta.io/allure/#_pytest)
```bash
pytest test_suite.py --alluredir=allure_results
```
2017-10-25 08:13:55 +08:00
2020-12-18 14:27:39 +08:00
<h3><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="32" /> Using a Proxy Server:</h3>
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.
2020-05-23 13:25:36 +08:00
2019-08-17 14:47:52 +08:00
```bash
pytest proxy_test.py --proxy=IP_ADDRESS:PORT
```
If the proxy server that you wish to use requires authentication, you can do the following (Chromium only):
2020-05-23 13:25:36 +08:00
2019-08-17 14:47:52 +08:00
```bash
2018-10-18 06:22:34 +08:00
pytest proxy_test.py --proxy=USERNAME:PASSWORD@IP_ADDRESS:PORT
```
SeleniumBase also supports SOCKS4 and SOCKS5 proxies:
```bash
pytest proxy_test.py --proxy="socks4://IP_ADDRESS:PORT"
pytest proxy_test.py --proxy="socks5://IP_ADDRESS:PORT"
```
2018-03-05 06:55:00 +08:00
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.
2020-05-23 13:25:36 +08:00
2019-08-17 14:47:52 +08:00
```bash
pytest proxy_test.py --proxy=proxy1
```
2019-02-28 17:52:50 +08:00
2020-12-18 14:27:39 +08:00
<h3><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="32" /> Changing the User-Agent:</h3>
2019-02-28 17:52:50 +08:00
2020-12-23 00:56:21 +08:00
🔵 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.
2020-05-23 13:25:36 +08:00
2019-02-28 17:52:50 +08:00
```bash
pytest user_agent_test.py --agent="Mozilla/5.0 (Nintendo 3DS; U; ; en) Version/1.7412.EU"
```
2020-12-18 14:27:39 +08:00
<h3><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="32" /> Building Guided Tours for Websites:</h3>
2019-04-18 15:51:46 +08:00
2021-01-29 11:28:00 +08:00
🔵 Learn about <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/tour_examples/ReadMe.md">SeleniumBase Interactive Walkthroughs</a> (in the ``examples/tour_examples/`` folder). It's great for prototyping a website onboarding experience.
2019-04-18 15:51:46 +08:00
2017-04-25 12:17:26 +08:00
<a id="utilizing_advanced_features"></a>
2020-12-18 14:27:39 +08:00
<h3><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="32" /> Production Environments & Integrations:</h3>
2015-12-05 05:11:53 +08:00
2020-12-23 00:05:23 +08:00
🔵 Here are some things you can do to set up a production environment for your testing:
2015-12-05 05:11:53 +08:00
2020-10-03 01:25:12 +08:00
* You can set up a [Jenkins](https://jenkins.io/) build server for running tests at regular intervals. For a real-world Jenkins example of headless browser automation in action, check out the <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/integrations/azure/jenkins/ReadMe.md">SeleniumBase Jenkins example on Azure</a> or the <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/integrations/google_cloud/ReadMe.md">SeleniumBase Jenkins example on Google Cloud</a>.
2015-12-05 05:11:53 +08:00
2020-05-13 06:41:25 +08:00
* You can use [the Selenium Grid](https://selenium.dev/documentation/en/grid/) to scale your testing by distributing tests on several machines with parallel execution. To do this, check out the [SeleniumBase selenium_grid folder](https://github.com/seleniumbase/SeleniumBase/tree/master/seleniumbase/utilities/selenium_grid), which should have everything you need, including the <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/utilities/selenium_grid/ReadMe.md">Selenium Grid ReadMe</a>, which will help you get started.
2015-12-05 05:11:53 +08:00
2020-05-13 06:41:25 +08:00
* If you're using the <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/mysql_installation.md">SeleniumBase MySQL feature</a> to save results from tests running on a server machine, you can install [MySQL Workbench](https://dev.mysql.com/downloads/tools/workbench/) to help you read & write from your DB more easily.
2017-04-25 12:17:26 +08:00
2015-12-05 05:11:53 +08:00
* If you use [Slack](https://slack.com), you can easily have your Jenkins jobs display results there by using the [Jenkins Slack Plugin](https://github.com/jenkinsci/slack-plugin). Another way to send messages from your tests to Slack is by using [Slack's Incoming Webhooks API](https://api.slack.com/incoming-webhooks).
2020-10-03 01:25:12 +08:00
* If you're using AWS, you can set up an [Amazon S3](https://aws.amazon.com/s3/) account for saving log files and screenshots from your tests. To activate this feature, modify [settings.py](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/config/settings.py) with connection details in the S3 section, and add "``--with-s3-logging``" on the command-line when running your tests.
2015-12-05 05:11:53 +08:00
2017-10-25 08:13:55 +08:00
Here's an example of running tests with additional features enabled:
2020-05-23 13:25:36 +08:00
2019-08-17 14:47:52 +08:00
```bash
2020-10-03 01:25:12 +08:00
pytest [YOUR_TEST_FILE.py] --with-db-reporting --with-s3-logging
2015-12-05 05:11:53 +08:00
```
2017-04-25 12:17:26 +08:00
<a id="detailed_method_specifications"></a>
2020-12-18 14:27:39 +08:00
<h3><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="32" /> Detailed Method Specifications and Examples:</h3>
2015-12-05 05:11:53 +08:00
2020-12-23 00:56:21 +08:00
🔵 Navigating to a web page: (and related commands)
2015-12-05 05:11:53 +08:00
```python
2017-04-25 12:17:26 +08:00
self.open("https://xkcd.com/378/") # This method opens the specified page.
2015-12-05 05:11:53 +08:00
2017-04-25 12:17:26 +08:00
self.go_back() # This method navigates the browser to the previous page.
2015-12-05 05:11:53 +08:00
2017-04-25 12:17:26 +08:00
self.go_forward() # This method navigates the browser forward in history.
2015-12-05 05:11:53 +08:00
2017-04-25 12:17:26 +08:00
self.refresh_page() # This method reloads the current page.
self.get_current_url() # This method returns the current page URL.
self.get_page_source() # This method returns the current page source.
2015-12-05 05:11:53 +08:00
```
2020-12-23 00:56:21 +08:00
<b>ProTip™:</b> You may need to use the <code>self.get_page_source()</code> method along with Python's <code>find()</code> command to parse through the source to find something that Selenium wouldn't be able to. (You may want to brush up on your Python programming skills for that.)
2020-05-23 13:25:36 +08:00
2015-12-05 05:11:53 +08:00
```python
2017-04-25 12:17:26 +08:00
source = self.get_page_source()
2019-03-12 12:53:01 +08:00
head_open_tag = source.find('<head>')
head_close_tag = source.find('</head>', head_open_tag)
everything_inside_head = source[head_open_tag+len('<head>'):head_close_tag]
2015-12-05 05:11:53 +08:00
```
2020-12-23 00:56:21 +08:00
🔵 Clicking:
2015-12-05 05:11:53 +08:00
To click an element on the page:
2020-05-23 13:25:36 +08:00
2015-12-05 05:11:53 +08:00
```python
self.click("div#my_id")
```
2017-04-25 12:17:26 +08:00
**ProTip™:** In most web browsers, you can right-click on a page and select ``Inspect Element`` to see the CSS selector details that you'll need to create your own scripts.
2020-12-23 00:56:21 +08:00
🔵 Typing Text:
2016-04-29 09:16:12 +08:00
2020-12-23 00:56:21 +08:00
<code>self.type(selector, text)</code> # updates the text from the specified element with the specified value. An exception is raised if the element is missing or if the text field is not editable. Example:
2020-05-23 13:25:36 +08:00
2016-04-29 09:16:12 +08:00
```python
2020-06-14 13:17:37 +08:00
self.type("input#id_value", "2012")
2016-04-29 09:16:12 +08:00
```
2020-12-23 00:56:21 +08:00
You can also use <code>self.add_text()</code> or the WebDriver <code>.send_keys()</code> command, but those won't clear the text box first if there's already text inside.
2016-04-29 09:16:12 +08:00
If you want to type in special keys, that's easy too. Here's an example:
2020-05-23 13:25:36 +08:00
2016-04-29 09:16:12 +08:00
```python
from selenium.webdriver.common.keys import Keys
2019-09-02 04:18:30 +08:00
self.find_element("textarea").send_keys(Keys.SPACE + Keys.BACK_SPACE + '\n') # The backspace should cancel out the space, leaving you with the newline
2016-04-29 09:16:12 +08:00
```
2020-12-23 00:56:21 +08:00
🔵 Getting the text from an element on a page:
2020-05-22 11:39:59 +08:00
2016-04-29 09:16:12 +08:00
```python
2017-04-25 12:17:26 +08:00
text = self.get_text("header h2")
```
2020-12-23 00:56:21 +08:00
🔵 Getting the attribute value from an element on a page:
2020-05-22 11:39:59 +08:00
2017-04-25 12:17:26 +08:00
```python
attribute = self.get_attribute("#comic img", "title")
2016-04-29 09:16:12 +08:00
```
2020-12-24 11:03:53 +08:00
🔵 Asserting existence of an element on a page within some number of seconds:
2020-05-22 11:39:59 +08:00
2015-12-05 05:11:53 +08:00
```python
self.wait_for_element_present("div.my_class", timeout=10)
```
(NOTE: You can also use: ``self.assert_element_present(ELEMENT)``)
2015-12-05 05:11:53 +08:00
2020-12-23 00:56:21 +08:00
🔵 Asserting visibility of an element on a page within some number of seconds:
2020-05-22 11:39:59 +08:00
2015-12-05 05:11:53 +08:00
```python
self.wait_for_element_visible("a.my_class", timeout=5)
```
2020-12-23 00:56:21 +08:00
(NOTE: The short versions of this are ``self.find_element(ELEMENT)`` and ``self.assert_element(ELEMENT)``. The find_element() version returns the element)
2015-12-05 05:11:53 +08:00
2016-01-12 09:48:50 +08:00
Since the line above returns the element, you can combine that with .click() as shown below:
2020-05-23 13:25:36 +08:00
2015-12-05 05:11:53 +08:00
```python
2016-04-29 09:16:12 +08:00
self.find_element("a.my_class", timeout=5).click()
2016-01-12 09:48:50 +08:00
# But you're better off using the following statement, which does the same thing:
self.click("a.my_class") # DO IT THIS WAY!
2015-12-05 05:11:53 +08:00
```
2017-07-21 09:16:57 +08:00
**ProTip™:** You can use dots to signify class names (Ex: ``div.class_name``) as a simplified version of ``div[class="class_name"]`` within a CSS selector.
You can also use ``*=`` to search for any partial value in a CSS selector as shown below:
2020-05-23 13:25:36 +08:00
2017-04-25 12:17:26 +08:00
```python
2017-07-21 09:16:57 +08:00
self.click('a[name*="partial_name"]')
2017-04-25 12:17:26 +08:00
```
2020-12-23 00:56:21 +08:00
🔵 Asserting visibility of text inside an element on a page within some number of seconds:
2020-05-22 11:39:59 +08:00
2015-12-05 05:11:53 +08:00
```python
2018-02-02 06:05:54 +08:00
self.assert_text("Make it so!", "div#trek div.picard div.quotes")
self.assert_text("Tea. Earl Grey. Hot.", "div#trek div.picard div.quotes", timeout=3)
2015-12-05 05:11:53 +08:00
```
2020-12-24 11:03:53 +08:00
(NOTE: ``self.find_text(TEXT, ELEMENT)`` and ``self.wait_for_text(TEXT, ELEMENT)`` also do this. For backwards compatibility, older method names were kept, but the default timeout may be different.)
2015-12-05 05:11:53 +08:00
2020-12-23 00:56:21 +08:00
🔵 Asserting Anything:
2020-05-22 11:39:59 +08:00
2015-12-05 05:11:53 +08:00
```python
self.assert_true(myvar1 == something)
2015-12-05 05:11:53 +08:00
self.assert_equal(var1, var2)
2015-12-05 05:11:53 +08:00
```
2020-12-23 00:56:21 +08:00
🔵 Useful Conditional Statements: (with creative examples in action)
2015-12-05 05:11:53 +08:00
is_element_visible(selector) # is an element visible on a page
2020-12-23 00:05:23 +08:00
2015-12-05 05:11:53 +08:00
```python
if self.is_element_visible('div#warning'):
2019-12-25 07:43:41 +08:00
print("Red Alert: Something bad might be happening!")
2015-12-05 05:11:53 +08:00
```
is_element_present(selector) # is an element present on a page
2020-12-23 00:05:23 +08:00
2015-12-05 05:11:53 +08:00
```python
if self.is_element_present('div#top_secret img.tracking_cookie'):
2019-08-18 05:23:40 +08:00
self.contact_cookie_monster() # Not a real SeleniumBase method
2015-12-05 05:11:53 +08:00
else:
2017-04-25 12:17:26 +08:00
current_url = self.get_current_url()
2019-08-18 05:23:40 +08:00
self.contact_the_nsa(url=current_url, message="Dark Zone Found") # Not a real SeleniumBase method
2015-12-05 05:11:53 +08:00
```
2020-05-23 13:25:36 +08:00
2015-12-05 05:11:53 +08:00
Another example:
2020-12-23 00:05:23 +08:00
2015-12-05 05:11:53 +08:00
```python
def is_there_a_cloaked_klingon_ship_on_this_page():
if self.is_element_present("div.ships div.klingon"):
return not self.is_element_visible("div.ships div.klingon")
return False
```
is_text_visible(text, selector) # is text visible on a page
2020-12-23 00:05:23 +08:00
2015-12-05 05:11:53 +08:00
```python
def get_mirror_universe_captain_picard_superbowl_ad(superbowl_year):
selector = "div.superbowl_%s div.commercials div.transcript div.picard" % superbowl_year
if self.is_text_visible("For the Love of Marketing and Earl Grey Tea!", selector):
return "Picard HubSpot Superbowl Ad 2015"
elif self.is_text_visible("Delivery Drones... Engage", selector):
return "Picard Amazon Superbowl Ad 2015"
elif self.is_text_visible("Bing it on Screen!", selector):
return "Picard Microsoft Superbowl Ad 2015"
elif self.is_text_visible("OK Glass, Make it So!", selector):
return "Picard Google Superbowl Ad 2015"
elif self.is_text_visible("Number One, I've Never Seen Anything Like It.", selector):
return "Picard Tesla Superbowl Ad 2015"
elif self.is_text_visible("""With the first link, the chain is forged.
The first speech censored, the first thought forbidden,
the first freedom denied, chains us all irrevocably.""", selector):
return "Picard Wikimedia Superbowl Ad 2015"
elif self.is_text_visible("Let us make sure history never forgets the name ... Facebook", selector):
return "Picard Facebook Superbowl Ad 2015"
else:
raise Exception("Reports of my assimilation are greatly exaggerated.")
```
2020-12-23 00:05:23 +08:00
🔵 Switching Tabs:
2015-12-05 05:11:53 +08:00
2020-12-23 00:05:23 +08:00
<p>What if your test opens up a new tab/window and now you have more than one page? No problem. You need to specify which one you currently want Selenium to use. Switching between tabs/windows is easy:</p>
2020-05-23 13:25:36 +08:00
2015-12-05 05:11:53 +08:00
```python
2019-09-02 04:18:30 +08:00
self.switch_to_window(1) # This switches to the new tab (0 is the first one)
2015-12-05 05:11:53 +08:00
```
2020-12-23 00:05:23 +08:00
🔵 <b>ProTip™:</b> iFrames follow the same principle as new windows - you need to specify the iFrame if you want to take action on something in there
2020-05-23 13:25:36 +08:00
2015-12-05 05:11:53 +08:00
```python
2017-04-25 12:17:26 +08:00
self.switch_to_frame('ContentManagerTextBody_ifr')
2015-12-05 05:11:53 +08:00
# Now you can act inside the iFrame
2017-04-25 12:17:26 +08:00
# .... Do something cool (here)
2019-09-02 04:18:30 +08:00
self.switch_to_default_content() # Exit the iFrame when you're done
2015-12-05 05:11:53 +08:00
```
2020-12-23 00:05:23 +08:00
🔵 Handling Pop-Up Alerts:
2015-12-05 05:11:53 +08:00
2020-12-23 00:05:23 +08:00
<p>What if your test makes an alert pop up in your browser? No problem. You need to switch to it and either accept it or dismiss it:</p>
2020-05-23 13:25:36 +08:00
2015-12-05 05:11:53 +08:00
```python
self.wait_for_and_accept_alert()
2015-12-05 05:11:53 +08:00
self.wait_for_and_dismiss_alert()
2015-12-05 05:11:53 +08:00
```
If you're not sure whether there's an alert before trying to accept or dismiss it, one way to handle that is to wrap your alert-handling code in a try/except block. Other methods such as .text and .send_keys() will also work with alerts.
2020-12-23 00:05:23 +08:00
🔵 Executing Custom jQuery Scripts:
2015-12-05 05:11:53 +08:00
2020-12-23 00:05:23 +08:00
<p>jQuery is a powerful JavaScript library that allows you to perform advanced actions in a web browser.
2015-12-05 05:11:53 +08:00
If the web page you're on already has jQuery loaded, you can start executing jQuery scripts immediately.
2020-12-23 00:05:23 +08:00
You'd know this because the web page would contain something like the following in the HTML:</p>
2020-05-23 13:25:36 +08:00
2015-12-05 05:11:53 +08:00
```html
2019-09-19 15:43:40 +08:00
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
2015-12-05 05:11:53 +08:00
```
2020-12-23 00:05:23 +08:00
🔵 It's OK if you want to use jQuery on a page that doesn't have it loaded yet. To do so, run the following command first:
2020-05-23 13:25:36 +08:00
2015-12-05 05:11:53 +08:00
```python
self.activate_jquery()
```
2020-12-23 00:05:23 +08:00
🔵 Some websites have a restrictive [Content Security Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP) to prevent users from loading jQuery and other external libraries onto their websites. If you need to use jQuery or another JS library on such a website, add ``--disable-csp`` on the command-line.
2018-11-09 00:15:00 +08:00
2020-12-23 00:56:21 +08:00
🔵 Here are some examples of using jQuery in your scripts:
2020-05-23 13:25:36 +08:00
2015-12-05 05:11:53 +08:00
```python
self.execute_script('jQuery, window.scrollTo(0, 600)') # Scrolling the page
self.execute_script("jQuery('#annoying-widget').hide()") # Hiding elements on a page
self.execute_script("jQuery('#hidden-widget').show(0)") # Showing hidden elements on a page
2015-12-05 05:11:53 +08:00
self.execute_script("jQuery('#annoying-button a').remove()") # Removing elements on a page
self.execute_script("jQuery('%s').mouseover()" % (mouse_over_item)) # Mouse-over elements on a page
self.execute_script("jQuery('input#the_id').val('my_text')") # Fast text input on a page
self.execute_script("jQuery('div#dropdown a.link').click()") # Click elements on a page
self.execute_script("return jQuery('div#amazing')[0].text") # Returns the css "text" of the element given
self.execute_script("return jQuery('textarea')[2].value") # Returns the css "value" of the 3rd textarea element on the page
```
2020-12-23 00:05:23 +08:00
🔵 In the next example, JavaScript creates a referral button on a page, which is then clicked:
2020-05-23 13:25:36 +08:00
2015-12-05 05:11:53 +08:00
```python
2018-02-13 01:35:25 +08:00
start_page = "https://xkcd.com/465/"
destination_page = "https://github.com/seleniumbase/SeleniumBase"
self.open(start_page)
referral_link = '''<a class='analytics test' href='%s'>Free-Referral Button!</a>''' % destination_page
self.execute_script('''document.body.innerHTML = \"%s\"''' % referral_link)
2015-12-05 05:11:53 +08:00
self.click("a.analytics") # Clicks the generated button
```
2020-12-23 00:05:23 +08:00
2018-02-22 11:46:47 +08:00
(Due to popular demand, this traffic generation example has been baked into SeleniumBase with the ``self.generate_referral(start_page, end_page)`` and the ``self.generate_traffic(start_page, end_page, loops)`` methods.)
2015-12-05 05:11:53 +08:00
2020-12-23 00:05:23 +08:00
🔵 Using deferred asserts:
2020-12-23 00:05:23 +08:00
<p>Let's say you want to verify multiple different elements on a web page in a single test, but you don't want the test to fail until you verified several elements at once so that you don't have to rerun the test to find more missing elements on the same page. That's where deferred asserts come in. Here's the example:</p>
2020-05-23 13:25:36 +08:00
```python
from seleniumbase import BaseCase
class MyTestClass(BaseCase):
2020-05-28 15:44:36 +08:00
def test_deferred_asserts(self):
self.open('https://xkcd.com/993/')
self.wait_for_element('#comic')
2020-05-28 15:44:36 +08:00
self.deferred_assert_element('img[alt="Brand Identity"]')
self.deferred_assert_element('img[alt="Rocket Ship"]') # Will Fail
self.deferred_assert_element('#comicmap')
self.deferred_assert_text('Fake Item', '#middleContainer') # Will Fail
self.deferred_assert_text('Random', '#middleContainer')
self.deferred_assert_element('a[name="Super Fake !!!"]') # Will Fail
self.process_deferred_asserts()
```
2020-12-23 00:56:21 +08:00
<code>deferred_assert_element()</code> and <code>deferred_assert_text()</code> will save any exceptions that would be raised.
To flush out all the failed deferred asserts into a single exception, make sure to call <code>self.process_deferred_asserts()</code> at the end of your test method. If your test hits multiple pages, you can call <code>self.process_deferred_asserts()</code> before navigating to a new page so that the screenshot from your log files matches the URL where the deferred asserts were made.
2020-12-23 00:05:23 +08:00
🔵 Accessing Raw WebDriver
2015-12-05 05:11:53 +08:00
2020-12-23 00:05:23 +08:00
<p>If you need access to any commands that come with standard WebDriver, you can call them directly like this:</p>
2020-05-23 13:25:36 +08:00
2015-12-05 05:11:53 +08:00
```python
2017-04-25 12:17:26 +08:00
self.driver.delete_all_cookies()
capabilities = self.driver.capabilities
self.driver.find_elements_by_partial_link_text("GitHub")
2015-12-05 05:11:53 +08:00
```
2020-12-23 00:05:23 +08:00
2017-04-25 12:17:26 +08:00
(In general, you'll want to use the SeleniumBase versions of methods when available.)
2015-12-05 05:11:53 +08:00
2020-12-23 00:05:23 +08:00
🔵 Retrying failing tests automatically:
2021-02-11 12:24:32 +08:00
<p>You can use <code>--reruns=NUM</code> to retry failing tests that many times. Use <code>--reruns-delay=SECONDS</code> to wait that many seconds between retries. Example:</p>
2020-05-23 13:25:36 +08:00
2020-12-23 00:05:23 +08:00
```bash
2021-02-11 12:24:32 +08:00
pytest --reruns=1 --reruns-delay=1
```
2020-12-23 00:05:23 +08:00
<p>Additionally, you can use the <code>@retry_on_exception()</code> decorator to specifically retry failing methods. (First import: <code>from seleniumbase import decorators</code>) To learn more about SeleniumBase decorators, [click here](https://github.com/seleniumbase/SeleniumBase/tree/master/seleniumbase/common).</p>
2015-12-05 05:11:53 +08:00
2020-12-18 14:27:39 +08:00
<h3><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="32" /> Wrap-Up</h3>
2015-12-05 05:11:53 +08:00
2020-05-22 11:39:59 +08:00
<b>Congratulations on getting started with SeleniumBase!</b>
2017-04-25 12:17:26 +08:00
2020-05-14 04:42:14 +08:00
<p>
<div><b>If you see something, say something!</b></div>
<div><a href="https://github.com/seleniumbase/SeleniumBase/issues?q=is%3Aissue+is%3Aclosed"><img src="https://img.shields.io/github/issues-closed-raw/seleniumbase/SeleniumBase.svg?color=22BB88" title="Closed Issues" /></a> <a href="https://github.com/seleniumbase/SeleniumBase/pulls?q=is%3Apr+is%3Aclosed"><img src="https://img.shields.io/github/issues-pr-closed/seleniumbase/SeleniumBase.svg?logo=github&logoColor=white&color=22BB99" title="Closed Pull Requests" /></a></div>
</p>
2018-12-15 09:29:30 +08:00
2020-05-14 04:42:14 +08:00
<p>
<div><b>If you like us, give us a star!</b></div>
<div><a href="https://github.com/seleniumbase/SeleniumBase/stargazers"><img src="https://img.shields.io/github/stars/seleniumbase/seleniumbase.svg?color=888CFA" title="Stargazers" /></a></div>
</p>
<p><div><a href="https://github.com/mdmintz">https://github.com/mdmintz</a></div></p>
2020-01-27 06:25:33 +08:00
2020-11-18 08:22:12 +08:00
<div><a href="https://github.com/seleniumbase/SeleniumBase/"><img src="https://seleniumbase.io/cdn/img/fancy_logo_14.png" title="SeleniumBase" width="290" /></a></div>
2018-03-09 11:52:43 +08:00
2020-05-14 04:42:14 +08:00
<div><a href="https://github.com/seleniumbase/SeleniumBase/blob/master/LICENSE"><img src="https://img.shields.io/badge/license-MIT-22BBCC.svg" title="SeleniumBase" /></a> <a href="https://github.com/seleniumbase/SeleniumBase/releases"><img src="https://img.shields.io/github/repo-size/seleniumbase/seleniumbase.svg" title="SeleniumBase" alt="Repo Size" /></a> <a href="https://gitter.im/seleniumbase/SeleniumBase"><img src="https://badges.gitter.im/seleniumbase/SeleniumBase.svg" title="SeleniumBase" alt="Join the chat!" /></a></div>
2020-05-13 07:58:43 +08:00
2020-05-19 08:07:16 +08:00
<div><a href="https://github.com/seleniumbase/SeleniumBase"><img src="https://img.shields.io/badge/tested%20with-SeleniumBase-04C38E.svg" alt="Tested with SeleniumBase" /></a> <a href="https://seleniumbase.io">
<img src="https://img.shields.io/badge/docs-%20%20SeleniumBase.io-11BBDD.svg" alt="SeleniumBase.io Docs" /></a></div>
2020-05-17 01:24:38 +08:00
2021-01-23 04:33:35 +08:00
<div><a href="https://pepy.tech/count/seleniumbase"> <img src="https://pepy.tech/badge/seleniumbase" alt="SeleniumBase PyPI downloads" /></a> <a href="https://twitter.com/SeleniumBase">
2021-01-22 08:08:00 +08:00
<img src="https://img.shields.io/twitter/follow/seleniumbase.svg?style=flat-rounded&logo=twitter&label=followers" alt="SeleniumBase Twitter followers" /></a></div>
2020-05-20 02:59:15 +08:00
<p><div><span><a href="https://github.com/seleniumbase/SeleniumBase"><img src="https://seleniumbase.io/img/social/share_github.svg" title="SeleniumBase on GitHub" alt="SeleniumBase on GitHub" width="56" /></a></span>
<span><a href="https://gitter.im/seleniumbase/SeleniumBase"><img src="https://seleniumbase.io/img/social/share_gitter.svg" title="SeleniumBase on Gitter" alt="SeleniumBase on Gitter" width="44" /></a></span>
2020-05-20 02:13:17 +08:00
<span><a href="https://twitter.com/seleniumbase"><img src="https://seleniumbase.io/img/social/share_twitter.svg" title="SeleniumBase on Twitter" alt="SeleniumBase on Twitter" width="60" /></a></span>
2020-05-20 02:59:15 +08:00
<span><a href="https://instagram.com/seleniumbase"><img src="https://seleniumbase.io/img/social/share_instagram.svg" title="SeleniumBase on Instagram" alt="SeleniumBase on Instagram" width="52" /></a></span>
<span><a href="https://www.facebook.com/SeleniumBase"><img src="https://seleniumbase.io/img/social/share_facebook.svg" title="SeleniumBase on Facebook" alt="SeleniumBase on Facebook" width="56" /></a></span></div></p>