Cross browser testing with Robot Framework

Cross Browser Testing with RobotFramework

RobotFramework is a generic keyword-driven test automation framework for acceptance level testing and acceptance test-driven development (ATDD).

Recently, Robot Framework has gained a lot of popularity in the testing community. I think its precisely because of its simplicity and flexibility. One can get setup and ready to write first test case in a matter of few minutes.

Robot Framework is extremely easy to set up, use and modify to get both Android and iOS apps tested. The test syntax that it uses is based on keywords and these keywords are quick to edit and further configure to make a match with the application under test.

Furthermore, testing capabilities provided by Robot Framework can be easily extended with the test libraries which can be implemented using Python, Java and even some other languages are supported.

Basic Setup

To get started with Robot Framework basically you need Python and pip installed. If you have the environment properly configured you can just execute the installation command lines:

pip install robotframework
pip install robotframework-seleniumLibrary

Anatomy of Test case

There are several ways to structure your test cases, In this post I will share just one of them.

Each test case file can have 4 sections

  1. Settings – You can use Settings to specify your imports, such as libraries and resources
  2. Variables – This section, you can define variables that are available in the scope of test case file
  3. Test Cases – This section, you can define your tests
  4. Keywords – Where you can define your methods/actions.

Test Scenario we can cover for sample test case is to use selenium library of RobotFramework, use Chrome driver to open browser, enter valid credentials and validate the title.

Code snippet for the same can be seen here:

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

*** Variables ***
${LOGIN URL}      http://localhost:7272
${BROWSER}        Chrome

*** Test Cases ***
Valid Login
    Open Browser To Login Page
    Input Username    demo
    Input Password    mode
    Submit Credentials
    Welcome Page Should Be Open
    [Teardown]    Close Browser

*** Keywords ***
Open Browser To Login Page
    Open Browser    ${LOGIN URL}    ${BROWSER}
    Title Should Be    Login Page

Input Username
    [Arguments]    ${username}
    Input Text    username_field    ${username}

Input Password
    [Arguments]    ${password}
    Input Text    password_field    ${password}

Submit Credentials
    Click Button    login_button

Welcome Page Should Be Open
    Title Should Be    Welcome Page

Keyword documentation of selenium library can be found here:

Feel free to drop a comment to this post or you can drop an email to [email protected]