---
title: SeleniumBase Python Cloud Testing | TestingBot
description: The SeleniumBase toolkit provides web automation and testing capabilities.
  Scripts use Python to instruct a remote browser.
source_url:
  html: https://testingbot.com/support/web-automate/selenium/python/seleniumbase
  md: https://testingbot.com/support/web-automate/selenium/python/seleniumbase/index.md
---
# SeleniumBase Browser Automation Framework

SeleniumBase is a Python-based framework that extends Selenium WebDriver, making it easier to write and run automated web tests.   
 SeleniumBase includes many built-in features such as visual testing, screenshot comparisons, and handling of dynamic web content.

One of the key highlights of SeleniumBase is its ability to integrate smoothly with popular Python testing frameworks like pytest.   
This enables parallel test execution, better test organization and improved scalability for larger projects.

## Setting up SeleniumBase

To install SeleniumBase, you can use pip to install the package:

    pip install seleniumbase

## Running your first test

Once you've installed SeleniumBase, you can create your first test that will connect to a remote TestingBot browser.

**Python Example:**

    from seleniumbase import BaseCase
    
    
    class DemoSiteTests(BaseCase):
        def test_demo_site(self):
            # Open a web page in the active browser window
            self.open("https://seleniumbase.io/demo_page")
    
            # Assert the title of the current web page
            self.assert_title("Web Testing Page")
    
            # Assert that an element is visible on the page
            self.assert_element("tbody#tbodyId")
    
            # Assert that a text substring appears in an element
            self.assert_text("Demo Page", "h1")
    
    
    if __name__ == " __main__":
        BaseCase.main( __name__ , __file__ )

You can now run this script on a TestingBot remote browser:

    pytest test_demo_site.py --server=API_KEY:API_SECRET@hub.testingbot.com --port=443 --protocol=https --cap_file=capabilities/cap_file_TB.py

The capabilities are passed as a file, in this case an example `cap_file_TB.py` could look like this:

    capabilities = {
        "browserName": "chrome",
        "browserVersion": "latest",
        "platformName": "WIN11",
        "tb:options": {
            "name": "SeleniumBase Test"
        }
    }

## Specify Browsers & Devices

To let TestingBot know on which browser/platform you want to run your test on, you need to specify the browsername, version, OS and other optional options in a capabilities file.

  ![OS selected](https://testingbot.com/assets/environments/svg/windows11-0e1b28bc0fdd5034d3e4d3dc8d346c500a8c6522facf4b45d0da56537c1f1c6d.svg) Windows 11 › ![Browser Selected](https://testingbot.com/assets/environments/svg/chrome-c4081ff447d2d898d4afcb8f074a907c960e6f007716c1a1d119eee6803c4042.svg) Chrome 139 

Loading environments...

Please wait while we load the available browsers and platforms.

    

## Testing Internal Websites

We've built [TestingBot Tunnel](https://testingbot.com/support/tunnel), to provide you with a secure way to run tests against your staged/internal webapps.  
Please see our [TestingBot Tunnel documentation](https://testingbot.com/support/tunnel) for more information about this easy to use tunneling solution.

The example below shows how to easily run a SeleniumBase test with our Tunnel:

1. [Download our tunnel](https://testingbot.com/support/tunnel) and start the tunnel:

    java -jar testingbot-tunnel.jar key secret

2. Adjust your test command to point to your tunnel's IP address:

    pytest test_demo_site.py --server=localhost --port=4445 --protocol=http --cap_file=capabilities/cap_file_TB.py

## Run tests in Parallel

Parallel Testing means running the same test, or multiple tests, simultaneously. This greatly reduces your total testing time.

SeleniumBase supports parallel test execution using pytest-xdist:

    pip install pytest-xdist

    pytest -n 4 --server=API_KEY:API_SECRET@hub.testingbot.com --port=443 --protocol=https --cap_file=capabilities/cap_file_TB.py

### Queuing

Every plan we provide comes with a limit of parallel tests.   
 If you exceed the number of parallel tests assigned to your account, TestingBot will queue the additional tests (for up to 6 minutes) and run the tests as soon as slots become available.

## Mark tests as passed/failed

As TestingBot has no way to determine whether your test passed or failed (it is determined by your business logic), we offer a way to send the test status back to TestingBot. This is useful if you want to see if a test succeeded or failed from the TestingBot member area.

You can use our [Python API client](https://github.com/testingbot/testingbotclient) to report back test results. Install it with:

    pip install testingbotclient

Call it from within your `BaseCase` test (for example in `tearDown`), where the WebDriver is available as `self.driver`:

    from testingbotclient import TestingBotClient
    
    client = TestingBotClient('API_KEY', 'API_SECRET')
    client.tests.update_test(
        self.driver.session_id,
        name='My Test',
        passed=True,
        build='build-123'
    )

## Other Python Framework examples

- [PyTest](https://testingbot.com/support/web-automate/selenium/python/pytest)

PyTest makes it easy to run Selenium tests with Python.

- [Behave](https://testingbot.com/support/web-automate/selenium/python/behave)

Behave is behaviour-driven development, Python style.

- [Lettuce](https://testingbot.com/support/web-automate/selenium/python/lettuce)

Lettuce is a Python BDD plugin based on Ruby's Cucumber, offering Gherkin stories.

- [PyUnit](https://testingbot.com/support/web-automate/selenium/python/pyunit)

PyUnit is the standard unit testing framework module for Python, described as a Python version of JUnit.

- [Helium](https://testingbot.com/support/web-automate/selenium/python/helium)

Helium is a tool that makes it easy to test websites and automate browsers.

- [Pylenium](https://testingbot.com/support/web-automate/selenium/python/pylenium)

Pylenium brings the best of Selenium, Cypress and Python into one package.

- [SeleniumBase](https://testingbot.com/support/web-automate/selenium/python/seleniumbase)

SeleniumBase is a Python package that simplifies Selenium testing.

- [Robot Framework](https://testingbot.com/support/web-automate/selenium/robotframework)

Robot Framework is a generic automation framework for acceptance testing.

## More Information

More information regarding SeleniumBase is available on the [SeleniumBase documentation](https://seleniumbase.io/seleniumbase/utilities/selenium_grid/ReadMe/).

### Looking for more help?

Have questions or need more information? Reach out via email or Slack.

[Email us](https://testingbot.com/contact/new)[Slack Join our Slack](https://join.slack.com/t/testingb0t/shared_invite/zt-3bcw9xch-jk19~6XPs_xBrsAgAedkCw)
