Set up your first robot framework test with webdriver

With Selenium2Library you can run WebDriver tests with Robot Framework.
Robot Framework is a test automation framework to run acceptance tests.

With robot framework you can build easy to read test cases. It allows using keyword driven, behavior driven approaches.
The framework provides reports in HTML format.

Setting up robot framework

Make sure you've installed pip, then to install the necessary libs:

pip install robotframework-selenium2library requests

Running your first test

Below is an example on how to run a simple test on Firefox. 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.txt file:

*** Settings ***

Library  Selenium2Library
Library  TestingBot

Test Setup  Open test browser
Test Teardown  Close test browser

*** Variables ***

${CREDENTIALS}  key:secret

*** Test Cases ***

Simple Test
    Go to
    Page should contain  Google

*** Keywords ***

Open test browser
    Open browser  about:  firefox
    ...  remote_url=http://${CREDENTIALS}
    ...  desired_capabilities=browserName:${BROWSER},version:${VERSION},platform:${PLATFORM}

Close test browser
    ...  Report TestingBot status
    ...  ${SUITE_NAME} | ${TEST_NAME}
    Close all browsers

Save this code in

import re
import requests
import base64

from robot.api import logger
from robot.libraries.BuiltIn import BuiltIn

def report_testingbot_status(name, status, credentials):
    selenium = BuiltIn().get_library_instance('Selenium2Library')
    session_id = selenium._current_browser().session_id

    token = base64.b64encode(credentials)
    payload = {'test[name]': name,
               'test[success]': int(status == 'PASS')}
    headers = {'Authorization': 'Basic {0}'.format(token)}

    url = '{0}'.format(session_id)
    response = requests.put(url, data=payload, headers=headers)
    assert response.status_code == 200, response.text

To run the test run this command

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

Once the test finished running, you should see it in the member dashboard. Use the variables to run the test on different platforms/browsers/versions.