Robot Python

Applies to CrossBrowserTesting SaaS, last modified on January 19, 2022

For this document, we provide an example test located in our Robot GitHub Repository.

Want a powerful and easy to use command line tool for running Selenium tests? Robot might be the option for you. Robot provides language-bindings for the powerful browser-driving tool Selenium.

Robot is an open source automation framework for acceptance testing that uses an easy-to-use tabular test data syntax and keyword driven testing approach. Robot integrates easily with the CrossBrowserTesting platform, so you can perform tests on a wide variety of OS/Device/Browser combinations, all from one test.

Let's walk through getting setup

Note: You will need to use your Username and Authkey to run your tests on CrossBrowserTesting To get yours, sign up for a free trial or purchase a plan.
  1. First we need to create a new folder and get Selenium for Robot installed. You can do this using pip:

    pip install robotframework-seleniumlibrary
  2. Next we need to create a test. This will be the Robot commands that work with the Selenium language bindings to create the logic of our test. Save the following as crossbrowsertesting.robot:

    *** Settings ***
    Documentation Simple example using SeleniumLibrary and CBT.
    Library SeleniumLibrary

    *** Variables ***
    ${Password} test123
    ${Delay} 5s
    ${RemoteUrl} http://${CBTUser}:${CBTAuth}
    ${Browser} Chrome
    ${Version} 77
    ${Platform} Windows 10
    ${Resolution} 1366x768
    ${ExpectedMessage} You are now logged in!
    ${Message} Successful Login!
    *** Keywords ***
    Open LoginPage
        Open Browser url=${SiteUrl} browser=${Browser} remote_url=${RemoteURL} desired_capabilities=name:${TestName},browserName:${Browser},version:${Version},platform:${Platform},screen_resolution:${Resolution}
    Maximize Browser
        Maximize Browser Window
    Enter User Name
        Input Text name=username ${Username}
    Enter Password
        Input Text name=password ${Password}
    Click Login
        Click Button id=submit
    Assert Warning Message
        Element Text Should Be id=logged-in ${ExpectedMessage} ${Message}

    *** Test Cases ***
    Login Should Succeed
        Open LoginPage
        Enter User Name
        Enter Password
        Click Login
        sleep ${Delay}
        Assert Warning Message
        [Teardown] Close Browser

  3. Be sure to add your CrossBrowserTesting username and CrossBrowserTesting authkey to your script.

  4. Congratulations! You have successfully integrated CrossBrowserTesting and Robot. Now you are ready to run your test using the command:

    robot crossbrowsertesting.robot

As you can probably make out from our test, we visit our simple login page example, interact with our page to log in, and use assertions to verify that our log in was successful.

We kept it short and sweet for our purposes, but there is so much more you can do with Robot! Being built on top of Selenium means the sky is the limit as far as what you can do. If you have any questions or concerns, feel free to contact Support.

See Also

Selenium and Python
Cucumber Ruby
TeamCity Integration

Highlight search results