---
title: Robot Framework Selenium Testing with TestingBot
description: Run Selenium tests with Robot Framework and SeleniumLibrary WebDriver.
  Run Robot Framework tests on our Selenium and Appium grid with 6100+ browser and
  device combinations.
source_url:
  html: https://testingbot.com/support/web-automate/selenium/robotframework
  md: https://testingbot.com/support/web-automate/selenium/robotframework/index.md
---
# Robot Framework Automated WebDriver Testing

See our [Robot Framework example repository](https://github.com/testingbot/robotframework-web-example) for a first example on how to run Robot Framework tests on TestingBot.

With [SeleniumLibrary](https://github.com/robotframework/SeleniumLibrary) you can run WebDriver tests with [Robot Framework](https://robotframework.org/).   
 Robot Framework is a test automation framework to run acceptance tests.

The Robot test framework allows you to build easy to read test cases, using keyword driven and behavior-driven approaches.   
 The framework provides reports, in HTML format.

## Setting up Robot Framework

Make sure you've installed [pip](https://pip.pypa.io/en/stable/), then install the necessary libraries:

    pip install robotframework-seleniumlibrary requests

### Running your first test

Below is an example on how to run a simple test on Chrome. When the test has finished, the test name and success state is sent to TestingBot so you can see the test success/failures in our dashboard.

Save the example below in a `test.robot` file:

[Browser Options](https://testingbot.com#)[Desired Capabilities (deprecated)](https://testingbot.com#)

This tab uses `desired_capabilities=`, which was removed in SeleniumLibrary 6.0 (April 2023). Use the **Browser Options** tab for modern SeleniumLibrary.

    ***Settings***
    
    Library SeleniumLibrary
    Library TestingBot
    
    Test Setup Open test browser
    Test Teardown Close test browser
    
    ***Variables***
    
    ${CREDENTIALS} key:secret
    
    ***Test Cases***
    
    Simple Test
        Go to https://www.google.com
        Page should contain Google
    
    ***Keywords***
    
    Open test browser
        Open browser about: chrome
        ... remote_url=https://${CREDENTIALS}@hub.testingbot.com/wd/hub
        ... desired_capabilities=browserName:${BROWSER},browserVersion:${VERSION},platformName:${PLATFORM}
    
    Close test browser
        Report TestingBot status
        ... ${SUITE_NAME} | ${TEST_NAME}
        ... ${TEST_STATUS} ${CREDENTIALS}
        Close all browsers

Save the code below in a `TestingBot.py` file:

    import requests
    from robot.libraries.BuiltIn import BuiltIn
    
    def report_testingbot_status(name, status, credentials):
        selenium = BuiltIn().get_library_instance('SeleniumLibrary')
        session_id = selenium.driver.session_id
    
        payload = {'test[name]': name, 'test[success]': int(status == 'PASS')}
        key, secret = credentials.split(':')
    
        url = f'https://api.testingbot.com/v1/tests/{session_id}'
        response = requests.put(url, data=payload, auth=(key, secret))
        assert response.status_code == 200, response.text

To run the test, run this command:

    PYTHONPATH=$PYTHONPATH:. robot --variable BROWSER:chrome --variable VERSION:latest --variable PLATFORM:WIN11 test.robot

Once the test finished running, you should see it in the [member dashboard](https://testingbot.com/members). Use the variables to run the test on different platforms/browsers/versions.

    ***Settings***
    
    Library SeleniumLibrary
    Library TestingBot
    Library BrowserOptions
    
    Test Setup Open test browser
    Test Teardown Close test browser
    
    ***Test Cases***
    
    Simple Test
        Go to https://www.google.com
        Page should contain Google
    
    ***Keywords***
    
    Open test browser
        ${options}= Get Browser Options ${BROWSER}
    
        # Set capabilities
        Call Method ${options} set_capability platformName ${PLATFORM}
        Call Method ${options} set_capability browserName ${BROWSER}
        Call Method ${options} set_capability browserVersion ${VERSION}
    
        # Set custom TestingBot capabilities using tb:options
        ${tb_options}= Create Dictionary key=${TB_KEY} secret=${TB_SECRET} name=test build=MyTestBuild
        Call Method ${options} set_capability tb:options ${tb_options}
    
        # Open browser with options
        Open Browser remote_url=https://hub.testingbot.com/wd/hub options=${options}
    
    Close test browser
        Report TestingBot status
        ... ${SUITE_NAME} | ${TEST_NAME}
        ... ${TEST_STATUS} ${TB_KEY}:${TB_SECRET}
        Close all browsers

Save the code below in a `TestingBot.py` file:

    import requests
    from robot.libraries.BuiltIn import BuiltIn
    
    def report_testingbot_status(name, status, credentials):
        selenium = BuiltIn().get_library_instance('SeleniumLibrary')
        session_id = selenium.driver.session_id
    
        payload = {'test[name]': name, 'test[success]': int(status == 'PASS')}
        key, secret = credentials.split(':')
    
        url = f'https://api.testingbot.com/v1/tests/{session_id}'
        response = requests.put(url, data=payload, auth=(key, secret))
        assert response.status_code == 200, response.text

Now we'll need to specify the multiple browser options in a file called `BrowserOptions.py`:

    from selenium.webdriver import ChromeOptions, FirefoxOptions, EdgeOptions, SafariOptions
    
    def get_browser_options(browser):
        if browser.lower() == 'chrome':
            return ChromeOptions()
        elif browser.lower() == 'firefox':
            return FirefoxOptions()
        elif browser.lower() == 'edge':
            return EdgeOptions()
        elif browser.lower() == 'safari':
            return SafariOptions()
        else:
            raise ValueError(f"Unsupported browser: {browser}")

To run the test, run this command:

    PYTHONPATH=$PYTHONPATH:. robot --variable BROWSER:chrome --variable VERSION:latest --variable PLATFORM:WIN11 --variable TB_KEY:API_KEY --variable TB_SECRET:API_SECRET test.robot

Once the test finished running, you should see it in the [member dashboard](https://testingbot.com/members). Use the variables to run the test on different platforms/browsers/versions.

### 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 the capabilities field.

    Call Method ${options} set_capability browserName ${BROWSER}
    Call Method ${options} set_capability browserVersion ${VERSION}
    Call Method ${options} set_capability platformName ${PLATFORM}

To see how to do this, please select a combination of browser, version and platform in the drop-down menus below.

  ![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 Robot Framework 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: instead of pointing to `'hub.testingbot.com/wd/hub'` like the example above - change it to point to your tunnel's IP address.   
 Assuming you run the tunnel on the same machine you run your tests, change to `'localhost:4445/wd/hub'`. localhost is the machine running the tunnel, 4445 is the default port of the tunnel.

This way your test will go securely through the tunnel to TestingBot and back.

## Parallel Testing

You can run multiple Robot Framework tests in parallel by using the [Pabot](https://pabot.org/) library.

First install Pabot using pip:

    pip install -U robotframework-pabot

Then run your tests using the `pabot` command instead of `robot`:

    PYTHONPATH=. pabot --processes 2 --loglevel TRACE --variable BROWSER:chrome --variable VERSION:latest --variable PLATFORM:WIN11 --variable TB_KEY:API_KEY --variable TB_SECRET:API_SECRET test.robot

Some recommendations when running tests in parallel:

- Make sure each test case is independent and does not rely on shared state.
- Specify the `--processes` with the same amount as your TestingBot plan allows (parallel test sessions).
- Consider using `--processtimeout` to set a timeout for each process.

### 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.

    from testingbotclient import TestingBotClient
    
    client = TestingBotClient('API_KEY', 'API_SECRET')
    client.tests.update_test(
        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.

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