Features
< Back to Blog Overview

Robot framework testing

2015-09-23
  • Share on Facebook
  • Share on Twitter
  • Share on LinkedIn
  • Share on HackerNews

With Robot Framework you can build easy to read test cases, which can then be run via Selenium WebDriver on our Selenium Grid.

It allows using keyword driven, behaviour driven approaches and provides reports in HTML format.

Setting up Robot Framework

First you have to make sure you've installed pip. To install the other libs, please run: 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:

Copy code
*** Settings ***

Library  Selenium2Library
Library  TestingBot

Test Setup  Open test browser
Test Teardown  Close test browser

*** Variables ***

${CREDENTIALS}  key:secret (get these for free from testingbot)

*** Test Cases ***

Simple Test
    Go to  https://www.google.com
    Page should contain  Google

*** Keywords ***

Open test browser
    Open browser  about:  firefox
    ...  remote_url=http://${CREDENTIALS}@hub.testingbot.com/wd/hub
    ...  desired_capabilities=browserName:firefox,version:62  

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

Save this code in TestingBot.py:

Copy code
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 = 'https://api.testingbot.com/v1/tests/{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: pybot test.txt Once the test has finished running, you will see it in the TestingBot member dashboard.

TestingBot Logo

Sign up for a Free Trial

Start testing your apps with TestingBot.

No credit card required.

Other Articles

blank

This week we've been adding many more browser versions to our list of browsers you can pick from. You can now instantly launch a Chrome browser ...

Read more
blank

Windows 10 is now available on TestingBot to use during both manual and automated testing (Selenium WebDriver). This is the latest OS version avai...

Read more
blank

With our TestingBot Tunnel you can easily and securely test your websites running on your local computer or internal network. When you download a...

Read more
New design for our Manual Testing Service

Today we're introducing a new design for our Manual Testing Service.

Read more
blank

Today we've updated our TestLab, where you can upload your Selenium IDE tests and schedule test-runs, with 2 new features. The first new feature ...

Read more
blank

If you're looking for a way to run tests after each git commit push, you can use the post-commit hook supplied by GIT.

Read more