Skip to main content

Robot Selenium :Run Automation Scripts on Selenium Grid using Robot Testing Framework

LambdaTest Selenium Automation Grid is a cloud based scalable Selenium testing platform which enables you to run your automation scripts on 2000+ different browsers and operating systems. You can now run your Selenium tests with Robot framework on a scalable Selenium infrastructure that is running real browsers and real operating systems. This post will help you in getting started with configuring and running your Python based automation test scripts on LambdaTest Selenium cloud platform. In this post we would be exploring:

  1. How to run a sample Selenium with Robot testing framework on LambdaTest Automation.
  2. How to set up an environment for Robot Selenium testing your locally hosted websites or web pages.
  3. How to configure Robot testing framework desired capabilities for executing a Selenium test.
  4. How to run your test cases in parallel to reduce build times
  5. Advanced features of LambdaTest.

Prerequisites For Running Robot Selenium Tests#

All the code samples in this documentation can be found in the Robot LambdaTest Repository on Image GitHub. You can either download or clone the repository to quickly run your tests.

1. Global Dependencies

  • Have Selenium WebDriver client driver installed inside your local Python environment.

  • Make sure that you have the latest Python build installed. You can download the latest Python build from

  • You would need Python package manager, pip, as well. Usually latest python installers come prepacked with pip. However if you don't have pip, you can install it using command:

    curl | python
  • Install Python with Homebrew

    $ brew install python
  • Download the driver from the link, or you can use pip to install it.

    pip install selenium
  • Make sure you have Robot testing framework installed in your system. In case you don't! Enter the below command:

    pip install robotframework
  • If you wish to test locally hosted or privately hosted projects, you would also need LambdaTest Tunnel binary file.

2. LambdaTest Authentication Credentials

  • You would need to your LambdaTest authentication credentials(Access key & Username). You need to update these credentials in the /Resources/Common.robot file.


3. Project Dependencies

  • Install necessary packages (use sudo if necessary)
    $ pip install -r requirements.txt

Getting Started With Robot Selenium & LambdaTest#

The first step in using LambdaTest platform is to understand LambdaTest's Selenium Grid capabilities. Our Selenium Grid uses remote webdriver instead of normal Selenium client browser drivers so if you are migrating from locally run Selenium, you would have to invoke LambdaTest Selenium remote webdriver. Next you need to specify in your code, which browser, browser versions, operating systems, and resolution you wish to run your test on, along with defining LambdaTest specific capabilities. You can checkout LambdaTest Capabilities Generator tool to understand more about how you can define running browser environments and leverage advanced LambdaTest capabilities.

Let' start with a simple Selenium Remote Webdriver test first. The Robot Selenium script below tests a simple to-do application with basic functionalities like mark items as done, add items in list, calculate total pending items etc. You can also find this at our GitHub repository.

Feature: Test to add item Scenario: Test sample-todo-app Given I go to sample-todo-app to add item Then I Click on first checkbox and second checkbox When I enter item to add When I click add button Then I should verify the added item

Now, we have to create step definition file.

*** Settings *** Resource  ../Resources/Common.robot Test Setup  Common.Open test browserTest Teardown  Common.Close test browser  *** Variables *** *** Test Cases *** Example of connecting to Lambdatest via Robot testing Framework     Page should contain element  name:li1    Page should contain element  name:li2     Click button  name:li1     Click button  name:li2              Input text  id:sampletodotext  Yey Let's add it to list    Click button  id:addbutton    ${response}    Get Text    xpath=/html/body/div/div/div/ul/li[6]/span    Should Be Equal As Strings    ${response}    Yey Let's add it to list

Here is common.robot file to setup mandatory details to run at LambdaTest.

*** Settings ***Library  Selenium2Library *** Variables *** @{_tmp}    ...  browserName: %{browserName},    ...  platform: %{platform},    ...  version: %{version},    ...  name: RobotFramework Lambda Test ${BROWSER}          %{ROBOT_BROWSER}${CAPABILITIES}     ${EMPTY.join(${_tmp})}${KEY}              <YOUR_LAMBDATEST_USERNAME>:<YOUR LAMBDATEST ACCESS KEY>${REMOTE_URL}       https://${KEY}  *** Keywords *** Open test browser    Open browser  browser=${BROWSER}    ...  remote_url=${REMOTE_URL}    ...  desired_capabilities=${CAPABILITIES} Close test browser    Close all browsers

Execute The Test Using Robot Testing Framework#

You would need to execute the below command in your terminal/cmd.

$ make test_Windows_10_chrome_68

Testing Locally Hosted Web Projects Using Robot Selenium#

To help you perform cross browser testing of your locally stored web pages, LambdaTest provides an SSH(Secure Shell) tunnel connection with the name LambdaTest Tunnel. With LambdaTest Tunnel, you can test your locally hosted files before you make them live over the internet. You could even perform cross browser testing from different IP addresses belonging to various geographic locations. You can also use LambdaTest Tunnel to test web-apps and websites that are permissible inside your corporate firewall. The SSH tunnel provided by LambdaTest acts as a proxy server for hosting your web pages from your local machine to Virtual machines running on LambdaTest cloud servers. Curious to know more about LambdaTest Tunnel?

Follow our documentation on LambdaTest Tunnel to know it all. OS specific instructions to download and setup tunnel binary can be found at the following links.

Download the binary file of:

You can start tunnel by executing the below command in your cmd(Command Prompt) / terminal. Make sure that your pointer is routed in the same directory where you extract the downloaded LambdaTest Tunnel zip file.

LT -user [user's login email] -key [user's access key]

So for example, if your user login email is [email protected] and your user key is 123asd123, then the command would be:

LT -user [email protected] -key 123asd123

How To Mark Tests As Pass Or Fail#

While performing automation testing using Selenium with Robot framework on LambdaTest selenium grid, you might want to flag a test as either pass or fail. This can be done if it is required in the testing requirements to validate the expected behaviour of tests. So you can mark any test as pass or fail, representing the expected outcome of that respective test. Below is the script that shows how to mark tests as pass or fail for validation:

LambdaTest Annotation

import osfrom robot.libraries.BuiltIn import BuiltIn
def report_lambdatest_status(name, status):    selenium = BuiltIn().get_library_instance('Selenium2Library')
    # Mark test status pass/failed    lambda_status = "passed"  if status=="PASS" else "failed"    lambda_status_script = 'lambda-status={}'.format(lambda_status)    selenium.execute_javascript(lambda_status_script)    # Update test name    lambda_status_script = 'lambda-name={}'.format(name)    selenium.execute_javascript(lambda_status_script)

Parallel Testing using Robot Testing Framework#

Parallel Testing is one of the most demanding feature of LambdaTest Selenium Grid. By parallel testing, you can run more than one test case, simultaneously. This means that, Parallel testing would allow you to execute numerous automation test cases altogether. So you execute a single test scenario across different browsers or could run different test scenarios across the same browser but with different browser versions.

To perform parallel Robot Selenium testing on LambdaTest's Online grid use the below command.

$ make run_all_in_parallel
Last updated on