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 PyPi 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
BaseCase.main(__name__, __file__)

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")

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

pytest test_demo_site.py --server=TB_KEY:TB_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:

platforms:
  - browserName: chrome
    browserVersion: latest
    platformName: WIN11
tb:name: ${BUILD_NUMBER}

Specifying the operating system, browser and version

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.

More Information

More information regarding SeleniumBase is available on the SeleniumBase documentation.

Was this page helpful?

Looking for More Help?

Have questions or need more information?
You can reach us via the following channels: