How To Use Robot Framework For Parallel Test Execution
Tags: testing, webdev, beginners, programming
Published: 2023-06-26 11:58:06


## How To Use Robot Framework For Parallel Test Execution



Over the years, there have been monumental changes in the processes used for developing, testing, and delivering software. Development & release cycles have become considerably short, with Continuous Integration and Continuous Delivery (CI/CD) catalyzing these changes.

[Continuous testing](https://www.lambdatest.com/learning-hub/selenium-interview-questions?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=learning_hub) is one of the guiding pillars of the continuous integration process, as it aids in accelerating feedback and improving product quality. There is a constant race against time, but acceleration shouldn’t be achieved at the cost of quality!

This is where automated testing at scale can prove beneficial in unearthing bugs and increasing the overall [test coverage](https://www.lambdatest.com/blog/code-coverage-vs-test-coverage/?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=blog). All of this can be achieved by accelerating the CI/CD pipelines with parallel tests (or parallel test execution). On a lighter note, [parallel testing](https://www.lambdatest.com/blog/what-is-parallel-testing-and-why-to-adopt-it/?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=blog) is one of the most trusted & reliable friends of CI/CD 🙂

The majority of the [test automation frameworks](https://www.lambdatest.com/blog/automation-testing-frameworks/?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=blog) provide the flexibility to run tests in parallel at different levels — *test, test suite, method, class,* and more. Though the level of parallelism depends on the nuances of the underlying framework, you need to choose the parallelism approach based on your execution requirements.

When it comes to [automated testing with Python](https://www.lambdatest.com/python-automation-testing?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=web_page), there is flexibility to choose from several frameworks — PyUnit, Pytest (or pytest), Behave, and Robot, amongst others.

Frameworks like pytest support parallel test execution out of the box, whereas parallel testing in Robot, PyUnit, etc., is enabled using supporting tools and libraries. In this blog on using the Robot framework for parallel test execution, I will cover how to run automation tests in parallel using the Robot framework on the local grid, as well as the [cloud Selenium grid](https://www.lambdatest.com/selenium-grid-online?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=web_page).

Let’s get started by quickly revisiting the concepts of the Robot framework for parallel test execution.
>  **Discover essential tips and [agile interview question](https://www.lambdatest.com/learning-hub/agile-interview-questions?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=learning_hub) in our comprehensive tutorial. Prepare effectively and ace your next agile interview. **

## What is Robot Framework?

For starters, Robot is a popular Python-based extensible keyword-driven open-source framework. It is primarily used for test automation, Acceptance Test Driven Development (ATDD), [Behavior Driven Development ](https://www.lambdatest.com/blog/behaviour-driven-development-by-selenium-testing-with-gherkin/?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=blog)(BDD), and Robotic Process Automation (RPA ).

The Robot framework uses an easy-to-read syntax that utilizes human-readable keywords. The framework-agnostic keywords define the actions that must be performed in a particular test.

{% youtube yf8AJqUc5Uo %}

Keywords in the Robot framework are divided into three categories:

## High-level keywords

High-level keywords provide an abstract representation of the underlying business functionality. They improve the readability and maintainability of the test cases since they can encapsulate low-level keywords.

They should resonate with the actions being performed in the said use case. Consider a banking application (or website) where users need to login before doing any financial transaction. *Login, Transfer Amount*, etc., are some of the high-level keywords in line with the business case.

![](https://cdn-images-1.medium.com/max/2680/0*fplwwQ4zhupaQnqe.png)

## Low-level keywords

Low-level keywords represent the operations performed as a part of the test scenario. These keywords, defined in libraries or resource files, can be either custom-built libraries or built-in keywords provided by the Robot framework.

Keywords that are a part of the *BuiltIn* library and *SeleniumLibrary* in Robot can be leveraged in automating test scenarios. *Should Contain, Should Be Equal, Skip If*, etc., are some of the keywords that are a part of the *BuiltIn* library. *Select From List By Value, Input Text, Click Button, Click Element, Wait Until Element Is Visible,* etc., are some of the prominent keywords that are a part of the *SeleniumLibrary*.

The *SeleniumLibrary* in Robot uses the [Selenium WebDriver](https://www.lambdatest.com/learning-hub/webdriver?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=learning_hub), which further helps automate interactions with the web browser.

Here is the sample usage of low-level keywords for creating high-level keywords.

![](https://cdn-images-1.medium.com/max/2784/0*mtUfjs7w1HTGnK6z.png)
>  **Here’s 295+ [Selenium Interview Questions ](https://www.lambdatest.com/learning-hub/selenium-interview-questions?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=learning_hub)with Answers that will help you boost your confidence in an Interview.**

## Technical keywords

Technical keywords are built-in keywords that help with [test management](https://www.lambdatest.com/learning-hub/test-management?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=learning_hub) and [test execution](https://www.lambdatest.com/learning-hub/test-execution?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=learning_hub). They help with logging, controlling execution flow, and error handling.

*Capture Page Screenshot, Capture Element Screenshot, Pass Execution If, Log, Log To Console,* etc., are some of the technical keywords in Robot. For instance, the keyword to Capture Element Screenshot can be leveraged for capturing a screenshot of a certain WebElement and comparing it across different releases.

In the below-mentioned example, we capture the screenshots of the entire webpage and the Button element. The screenshots are placed in a customized directory instead of *${OUTPUT_DIR}* (or present working directory).

![](https://cdn-images-1.medium.com/max/3200/0*Z-JdHr311X-cjJUz.png)

Along with *BuiltIn* and *SeleniumLibrary*, we have also included the *OperatingSystem* library for using Directory-related keywords (i.e., *Create Directory* and *​​Directory Should Exist*).

## Robot Framework Architecture

Robot is an open-source, extensible, and language-independent framework. All of this is possible using the test libraries written in that particular programming language.

The *Remote Library Interface* allows the test libraries to be run as external processes. It uses the XML-RPC protocol for communication; hence test libraries can be implemented for programming languages (e.g., Java, C#, JavaScript, etc.) that support the protocol. For example, the *jrobotremoteserver* is a remote server for the Robot framework implemented using Java.

Here are some of the major building blocks of the Robot Framework:

## Robot Framework

Referred to as the framework’s core which is implemented in Python. It is primarily responsible for test execution and test case management.

The core has no information regarding the TUT (Target Under Test), as the entire interaction is handled by the test libraries. It is also responsible for features related to logging and reporting.

## Test Data

As the name indicates, test data serves as the input to the test cases. The test data is written in a tabular format to enhance the maintainability of the tests.

Once the Robot framework receives the input data, it starts executing the test scenarios and generates detailed reports in HTML format. Robot also offers integration with popular reporting tools & dashboards like Allure, Report Portal, and Grafana.

![](https://cdn-images-1.medium.com/max/2000/0*vBnygrkl-cI8QxhO.png)

[High-level Architecture — Robot Framework](https://www.lambdatest.com/blog/wp-content/uploads/2020/09/Robot-Framework-Architecture.jpg?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=blog)
>  **Get ready to ace your JUnit interviews in 2023 with our comprehensive list of 90 [junit interviews questions](https://www.lambdatest.com/learning-hub/Junit-interview-questions?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=learning_hub) and answers that will help you sharpen your testing skills.**

## Test Libraries

As seen in the architecture diagram, Test Libraries act as the bridge (or interface) between the Robot Framework Core and SUT. Test libraries in Robot contain the keywords, thereby improving its maintainability & reusability.

Apart from *Robot Standard Libraries, SeleniumLibrary* in Robot can be extensively used when performing automated testing using the framework. Do check out this exhaustive list of Robot libraries that comprises mid-level (framework) Libraries, low-level (driver) Libraries, and Remote Libraries.

## System Under Test (SUT)

This is the target on which the automated tests are performed. It could be either a website or a web application.

[Test Cases](https://www.lambdatest.com/learning-hub/test-case?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=learning_hub) in Robot consist of Test Steps that, in turn, use the Test Libraries for realizing interactions with the SUT. Like any other test automation framework, test cases can be organized in test suites for improved maintenance.

## Benefits of Parallel Testing in Robot Framework

The Robot framework does offer out-of-the-box support for parallel test execution. However, it recommends the usage of Pabot — a parallel test executor for tests written using the Robot framework.

Before we deep dive into using the Robot framework for parallel test execution with Pabot, let’s quickly revisit the salient benefits of parallel test execution.

## Accelerated Test Execution

By default, Robot tests run in a sequential manner. The serial execution applies to tests as well as test suites. Even if a single test takes a few seconds to execute, the complete test execution time might go up to a few minutes (for a significantly last test suite).

Running tests serially might yield results in the short run, but the approach falters when test suites consisting of numerous tests have to be executed in a CI/CD pipeline. This is where parallel testing in Robot can be highly instrumental, as it helps accelerate the test execution by leveraging parallelism at the test and/or test-suite level.

## Increased Test Coverage

Parallel test execution in Robot helps improve product quality, as tests are run across different input combinations. The said combination can consist of generic input values (e.g., input URL, email address), browser names, browser versions, platform names, etc., depending on the scenario under test.

Below is an example of a Robot script where tests will be executed in parallel on Chrome and Safari browsers. This logic can be further scaled to run tests on different input combinations.

![](https://cdn-images-1.medium.com/max/2244/0*AV6RpHlA4OANXpk4.png)

All of this eventually helps increase the overall test coverage and identify issues at a significantly faster pace.
>  **This exhaustive list of [TestNG interview questions](https://www.lambdatest.com/learning-hub/testng-interview-questions?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=learning_hub) will aid you in strengthening your position as a candidate for the TestNG interview.**

## Faster Feedback Cycles

As seen so far, there are umpteen benefits of [speeding up test cycles ](https://www.lambdatest.com/blog/speed-up-testing-cycle/?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=blog)using parallel test execution. Another major benefit of parallel testing is shortened feedback loops for issue discovery, bug fixes, and testing the fixes for potential side effects.

The same guiding principles also apply to the Robot framework, as continuous testing with Robot can be realized by running parallel tests in a CI pipeline. Jenkins, GitLab, TeamCity, Azure DevOps, and GitHub Actions are some of the [top CI/CD tools ](https://www.lambdatest.com/blog/best-ci-cd-tools/?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=blog)supported by the Robot framework.

The combination of parallel testing & CI/CD aids in improving the effectiveness of the pipeline, shortening feedback cycles, and improving product quality at every step of product development.

## Achieve More with Fail-Fast Approach

Consider a scenario where you have 100’s of tests triggered in a CI/CD pipeline but only a selected few (e.g., 10 tests) fail all the time. What if these 10 *independent* tests are run in parallel in the next execution cycle? This approach will be instrumental in ensuring that tests are completed quickly or fail-fast, thereby helping save time as well as crucial $!

It is essential to note that tests when executed in parallel, might exhibit flakiness in case tests are interdependent or reliant on any sort of ordering. Apart from following [Selenium’s best practices](https://www.lambdatest.com/blog/selenium-best-practices-for-web-testing/?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=blog) for test case design, you could also look at reducing the number of parallel processes.

Robot framework provides the flexibility to re-run only failed tests, post which the results can be merged into a single results file using *rebot*.

![](https://cdn-images-1.medium.com/max/2816/0*Jg5pbRKfu-C1ghxP.png)

You can refer to the [Robot official documentation](https://docs.robotframework.org/docs/flaky_tests) that deep dives into flaky-test management and re-execution of failed tests.

Apart from the benefits mentioned above, I would recommend revisiting this blog that deep-dives into all the major [benefits of parallel testing](https://www.lambdatest.com/blog/what-is-parallel-testing-and-why-to-adopt-it/?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=blog). Now that the platform is all set let’s look at how to leverage Pabot (Parallel Robot Framework) for realizing parallel test execution.
>  **Here’s a list of 70 [Cucumber Interview Questions ](https://www.lambdatest.com/learning-hub/cucumber-interview-questions?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=learning_hub)and Answers that will help you boost your confidence in an Interview.**

## Introduction to Pabot (Parallel Robot Framework)

The Robot framework executes individual tests and tests within multiple test suites in a sequential manner. In case you want a quick recap of Robot, look at this detailed [Robot framework tutorial](https://www.lambdatest.com/blog/robot-framework-tutorial/?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=blog), where we have covered all the essential aspects of Robot, including test execution on local and cloud Selenium grid(s).

As mentioned earlier, Pabot is a parallel test runner for the Robot framework. Pabot lets you run Robot tests in parallel at test-level as well as test-suite level.

By default, Pabot does parallelization at the test suite level. Each process has its own memory space and runs a single test suite. In this case, individual tests within the test suite run sequentially, whereas all the test suites (*e.g., test1.robot, test2.robot*, etc.) run in parallel.

Resource file(s) normally houses reusable components like high-level keywords, variables, libraries, and other settings normally used across tests and test suites.

Below is an example Resource file (*e.g., common.robot*):

![](https://cdn-images-1.medium.com/max/3200/0*2s2tLeBr8gDvaGGj.png)

*Sample Resource File*
>  **Get ready for your BDD interview with 100+ [BDD interview questions.](https://www.lambdatest.com/learning-hub/bdd-interview-questions?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=learning_hub) Boost your confidence and impress your interviewer with this comprehensive guide covering principles & techniques.**

## Installation

Like any other Python package, Pabot can also be installed globally or inside a virtual environment (*venv*). At the time of writing this blog on using Robot framework for parallel test execution, the latest version of Pabot is 2.15.0.

**Global installation of Pabot**

Invoke the following command on the terminal to install Pabot:

    pip3 install -U robotframework-pabot

![](https://cdn-images-1.medium.com/max/3200/0*aCR5P34I9QGE_BbQ.png)

Though *pip3* is the recommended package manager for Python 3.x, you can still use *pip* with Python 3.x. In that case, the installation command is *pip install -U robotframework-pabot*.

**Pabot installation in Virtual Environment (virtualvenv)**

Virtual Environment (virtualvenv) provides much-need isolation of builds, thereby providing better management of Python packages for different projects.

Follow the below-mentioned steps for installing Pabot in venv:

 1. Run the command *pip3 install virtualenv* on the terminal if venv is not installed on your machine.

![](https://cdn-images-1.medium.com/max/3200/0*GidW_dubw0OSwtxW.png)

2. Create a virtual environment in the project folder by invoking the *virtualenv venv* command on the terminal. It is important to note that the environment name (i.e., *venv* in our case) is arbitrary.

![](https://cdn-images-1.medium.com/max/3200/0*_bZBFELWcx8GGaoF.png)

3. Activate the environment (i.e., *venv*) by invoking the source *venv/bin/activate* command on the terminal.

![](https://cdn-images-1.medium.com/max/2592/0*qIvrOpFvJVWcfoqp.png)

4. Invoke the command *pip3 install robotframework-pabot* to install the latest version of Pabot.

![](https://cdn-images-1.medium.com/max/3200/0*OS7u2Cx6IYlbF7Sk.png)
>  **Navigate your Laravel interview with ease! Our guide covers over 190 [Laravel interview questions](https://www.lambdatest.com/learning-hub/laravel-interview-questions?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=learning_hub) to help you land your ideal tech job.**

## Usage

Now that the Pabot installation is successful, let’s look at the commands to achieve parallelism at test and test-suite levels. By default, Pabot splits the execution at the suite level. Every process runs a single suite, you can also configure the number of parallel executors using the *–processes* option.

If not specified, Pabot enables two CPU cores that run one process each. Specifying all in *–processes* creates as many processes as the number of executable test suites or tests. However, this option must be used with caution, as too much parallelism might affect the performance and/or cause invalid test failures.

**Parallel Execution with Pabot at suite-level (default)**

    pabot [path to tests]

For instance, the command shown below starts 2 processes and runs test suites located in *Tests/CloudGrid* folder in parallel.

    pabot — verbose Tests/CloudGrid

As seen below, two processes (with PID 91894 and 91895) running in parallel are executing different test suites.

![](https://cdn-images-1.medium.com/max/3200/0*WnwJVxDXEBrWJiPL.png)

**Parallel Execution with Pabot at test level**

    pabot — verbose — testlevelsplit [path to tests]

For instance, the command shown below starts 2 processes and runs individual tests located in test suites in the *Tests/CloudGrid* folder in parallel.

    pabot — verbose — testlevelsplit Tests/CloudGrid

As seen below, two processes (with PID 93731 and 93732) running in parallel are executing two separate tests — App.Example 1 & App.Example 2

![](https://cdn-images-1.medium.com/max/3200/0*CeMZOOK1nA_FWkOE.png)

**Customize the number of parallel processes**

As mentioned earlier, the *–processes* option lets you achieve the same. Simply specify the number of processes (in integer format) that you want to start in parallel.

    pabot — verbose — processes <num_of_processes>

In the below command, we have specified the number of parallel processes as 4 with parallelism at the test level. However, only 3 parallel processes (PID — 95319, 95320, and 95320) are kick-started since maximum tests in a particular test-suite is 3.

    pabot — verbose — testlevelsplit — processes 4 <path_to_tests>

![](https://cdn-images-1.medium.com/max/3200/0*Jq9gMGl0tdq6R6Y4.png)

Run *pabot –help* on the terminal in case you want to have a look at other options supported by the runner.

![](https://cdn-images-1.medium.com/max/3200/0*87In1r3qrwADWGHd.png)
>  **Ace your [Unit testing interview questions](https://www.lambdatest.com/learning-hub/unit-testing-interview-questions?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=learning_hub) with our comprehensive interview questions and solutions for unit testing, covering topics from syntax to advanced techniques.**

In a nutshell, Pabot can be used for parallel test execution to optimize resource utilization by leveraging the available memory and CPU cores in the machine.

Now that we have covered all the essentials of Pabot, let’s look at using Robot framework for parallel test execution on Local Grid as well as LambdaTest cloud Grid.

## Demo: Parallel Testing in Selenium Robot using Pabot

The primary pre-requisite for the demonstration is Python 🙂, you can refer to [getting started with Selenium Python](https://www.lambdatest.com/blog/getting-started-with-selenium-python/?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=blog) in case you need a quick recap of Python for Selenium automated testing. For demonstrating parallel testing with Robot using Pabot, I would be running the same test scenarios across the local grid and LambdaTest cloud grid.

*I am using a macOS (Ventura 13.4) machine with the latest versions of Chrome and Safari installed. Some of the steps might vary in case you are using some other platform (e.g., Windows).*

### **Test Suite 1**

**Test Scenario — 1**

 1. Navigate to [https://lambdatest.github.io/sample-todo-app/](https://lambdatest.github.io/sample-todo-app/).

 2. Select the first two checkboxes.

 3. Send ‘Yey Let’s add it to list’ to the textbox with id = sampletodotext.

 4. Click the Add Button and verify whether the text has been added or not.

**Test Scenario — 2**

 1. Navigate to [https://lambdatest.github.io/sample-todo-app/](https://lambdatest.github.io/sample-todo-app/)

 2. Select the first, second, and fifth checkboxes.

 3. Send ‘Yey Let’s add it to list’ to the textbox with id = sampletodotext.

 4. Click the Add Button and verify whether the text has been added or not.

### **Test Suite 2**

**Test Scenario — 1**

 1. Navigate to [https://www.lambdatest.com/selenium-playground/](https://www.lambdatest.com/selenium-playground/)

 2. Click on the element ‘Input Form Submit’.

 3. Enter all the required details in the newly opened form.

 4. Submit the items.

## Project Prerequisites

Before I deep dive into the implementation, let’s do a quick walk-through of the setup used for implementing the scenarios. I am using Visual Studio (VS) Code IDE and Poetry Package Manager (instead of pip) as it simplifies project management to a huge extent.

Follow the below-mentioned steps for creating a Robot project in VS Code:

**Step 1**

After adding the project in VS Code, please run the command to create a virtual environment after navigating to the parent project folder.

    virtualenv venv

    source venv

![](https://cdn-images-1.medium.com/max/3200/0*GpZLIMK7-2ZFtrpY.png)

**Step 2**

Install Poetry by invoking the following command on the terminal:

    pip3 install poetry

![](https://cdn-images-1.medium.com/max/3200/0*WgfOJLB_xcY1wj95.png)

**Step 3**

Dependencies, plugins, and build configurations are a part of *pyproject.toml.* In our case, we have already added the respective packages and dependencies in *project.toml*.

    [tool.poetry]
    name = "robot-parallel-tests"
    version = "0.1.0"
    description = ""
    authors = ["Himanshu Jagdish Sheth <himanshu.sheth@gmail.com>"]
    readme = "README.md"
    
    
    [tool.poetry.dependencies]
    python = "^3.11"
    selenium = "4.9.0"
    flake8 = "^6.0.0"
    autopep8 = "^2.0.2"
    
    
    [build-system]
    requires = ["poetry-core"]
    build-backend = "poetry.core.masonry.api"

If *pyproject.toml* is not present for your project, run the command *poetry init* on the terminal. Post that, select the following packages using Poetry (via pyproject.toml):

* Python (v 3.11.0)

* Selenium (v 4.9.0)

* Flake8

* Autopep8

Select the relevant package name and version from the list (e.g., selenium, autopep8, etc.).

![](https://cdn-images-1.medium.com/max/3200/0*JFcG48t6gDxDG2JK.png)

![](https://cdn-images-1.medium.com/max/3156/0*nxabgmd3HsvAF1md.png)

![](https://cdn-images-1.medium.com/max/3156/0*J_6tf9sEHIFiEUo5.png)

Once all the packages are selected for *pyproject.toml*, press *Enter* to complete the generation of the file.

![](https://cdn-images-1.medium.com/max/3100/0*ciH2tGVMzA5cgIU6.png)
>  **This questionnaire intends to provide a list of some of the most frequently asked [Jenkins interview questions ](https://www.lambdatest.com/learning-hub/jenkins-interview-questions?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=learning_hub)to assist job seekers in preparing for interviews.**

**Step 4**
Invoke the command *poetry install* for setting up the project configurations. On completion, this will generate the files *pyproject.toml* and p*oetry.lock*.

![](https://cdn-images-1.medium.com/max/3200/0*zT6pYv4GcyP-eVrI.png)

**Step 5**
Install the project dependencies (i.e., *selenium, robotframework, and robotframework-seleniumlibrary*).

    selenium==4.9.0
    robotframework
    robotframework-seleniumlibrary

Invoke the command *pip3 install -r requirements.txt* to install the project dependencies (or packages).

![](https://cdn-images-1.medium.com/max/3200/0*-dy_jB8S19hntEbj.png)

## Project Setup

Shown below is the project setup that will be used in the Robot framework for parallel test execution on the local grid and LambdaTest cloud grid.

![](https://cdn-images-1.medium.com/max/2000/0*9LL9k8qujNCee6TN.png)

Here is a gist of the overall folder structure:

* **Resources/PageObject**

This folder contains three subfolders — *Common, KeyDefs,* and Locators that contain implementation related to test execution status and high-level keywords used in the tests.

![](https://cdn-images-1.medium.com/max/2000/0*bFTzRWnbz4Z9e0Vs.png)

* **Tests**

As the name indicates, Tests contain implementation of the actual tests using the Robot framework for parallel test execution with the Pabot runner.

Since the demo will be performed on the local grid and the cloud-based LambdaTest grid, we have segregated the test implementation into separate subfolders — LocalGrid and CloudGrid

![](https://cdn-images-1.medium.com/max/2000/0*3Zj1f8MCJ-RytfoL.png)

Apart from the folders mentioned above, we have *pyproject.toml* & *requirements.txt* that contain build system-related settings & project dependencies, respectively.

For better continuity, I will cover aspects related to execution on the cloud grid in a separate section.
>  **Here’s Top 30+ [CI CD Interview Questions](https://www.lambdatest.com/learning-hub/cicd-interview-questions?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=learning_hub) and Answers that will help you boost your confidence in an Interview.**

## Implementation

For better code maintainability, we have used P[age Object Model (POM) in Selenium Python](https://www.lambdatest.com/blog/page-object-model-in-selenium-python/?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=blog) to decouple the dependency between the locators and test code. Let’s dive deep into the specifics of the implementation!

* **Resources/PageObject/Locators**

To ensure that changes in the locators have minimal impact on the test code, locators used in the test cases are placed in the Locators.py file.

    
    # ToDo Page Locators
    
    
    FirstItem = "name:li1"
    SecondItem = "name:li2"
    FifthItem = "name:li5"
    AddButton = "id:addbutton"
    ToDoText = "id:sampletodotext"
    
    
    NewItemText = "Yey Let's add it to list"
    NewAdditionText = "xpath=/html/body/div/div/div/ul/li[6]/span"
    
    
    # Selenium Playground Page Locators
    
    
    SubmitButton = "xpath=//a[.='Input Form Submit']"
    Name = "name:name"
    email = "id:inputEmail4"
    passwd = "//input[@name='password']"
    company = "//input[@id='company']"
    website = "css=#websitename"
    country = "name:country"
    city = "//input[@id='inputCity']"
    address1 = "id:inputAddress1"
    address2 = "id:inputAddress2"
    state = "css=#inputState"
    city = "//input[@id='inputCity']"
    zip code = "css=#inputZip"
    FinalSubmission = "xpath=//*[@id='seleniumform']/div[6]/button"
    
    
    SuccessText = "Thanks for contacting us, we will get back to you shortly."

Here, we have used different [locators in Selenium](https://www.lambdatest.com/blog/selenium-locators-cheat-sheet/?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=blog), like ID, CSS Selector, linkText, XPath, etc., to locate WebElements on the page. The WebElements can be located using built-in Inspect Tools or plugins like [SelectorsHub](https://www.lambdatest.com/blog/selectorshub-the-next-gen-xpath-css-selectors-tool/?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=blog), POM Builder, etc.

Let’s take the case of the URL https://lambdatest.github.io/sample-todo-app/ used in Test Scenario — 1. The [Name locator in Selenium](https://www.lambdatest.com/blog/how-to-use-name-locator-in-selenium-automation-scripts/?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=blog) is used for locating the elements ‘First Item’ and ‘Second Item’.

![](https://cdn-images-1.medium.com/max/3200/0*HHa2Dwd_MvwciEJh.png)

On similar lines, the [ID locator in Selenium](https://www.lambdatest.com/blog/making-the-move-with-id-locator-in-selenium-webdriver/?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=blog) is used for locating the ‘Add’ button on the page.

![](https://cdn-images-1.medium.com/max/3200/0*ZfB8pLMOn6zoTWLe.png)

Lastly, once the new item is added to the ToDo list, it is located using the [XPath locator in Selenium](https://www.lambdatest.com/blog/complete-guide-for-using-xpath-in-selenium-with-examples/?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=blog).

![](https://cdn-images-1.medium.com/max/2460/0*F-SnIn7KC7A82b5N.png)

On similar lines, we have used the combination of CSS Selectors, Name, ID, and XPath locators for locating WebElements on [LambdaTest Selenium Playground.](https://www.lambdatest.com/selenium-playground/?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=web_page)

![](https://cdn-images-1.medium.com/max/3200/0*oBmxeMMA7KRyDG8V.png)



![](https://cdn-images-1.medium.com/max/3200/0*e7du23ceJHyA9cqh.png)

In case you have any confusion in choosing the best-suited selectors, do look at the [CSS Selectors vs XPath guide](https://www.lambdatest.com/blog/xpath-vs-css-selectors/?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=blog) for making a more informed decision.

* **Resources/PageObject/KeyDefs**

* Opening & Closing web browser on local grid

* Opening & Closing web browser on a particular OS on LambdaTest cloud grid

 

```
 Settings 
    Library  SeleniumLibrary
    Library  OperatingSystem
    Library  BuiltIn
    Library  ../Common/LambdaTestStatus.py
    
    
    *** Variables ***
    ${REMOTE_URL}       @hub.lambdatest.com/wd/hub">http://%{LT_USERNAME}:%{LT_ACCESS_KEY}@hub.lambdatest.com/wd/hub
    ${TIMEOUT}          3000
    
    
    *** Keywords ***
    Open test browser
       [Arguments]     ${TEST_URL}     ${BROWSER}      ${CAPABILITIES}
       [Timeout]       ${TIMEOUT}
       Open browser    ${TEST_URL}     ${BROWSER}
       ...  remote_url=${REMOTE_URL}
       ...  desired_capabilities=${CAPABILITIES}
    
    
    Close test browser
       Run keyword if  '${REMOTE_URL}' != ''
       ...  report lambdatest status
       ...  ${TEST_NAME}
       ...  ${TEST_STATUS}
       Close Browser
    
    
    Open local test browser
       [Arguments]     ${TEST_URL}     ${BROWSER}
       [Timeout]       ${TIMEOUT}
       Open browser    ${TEST_URL}     ${BROWSER}
    
    
    Close local test browser
       Close Browser
```

To get started, we include all the relevant libraries, resource files, and variable files in the *Settings* section. As seen below, we have imported the *SeleniumLibrary*, which provides low-level keywords for automating interactions with the elements on the page.

![](https://cdn-images-1.medium.com/max/2000/0*o84xHMQW1RulKpQD.png)

It is important to note that Selenium2Library has been renamed to SeleniumLibrary since Robot version 3.0. Hence, we have used SeleniumLibrary throughout this blog on using Robot Framework for parallel test execution.

Open local test browser is a high-level keyword that takes two input arguments — Test URL and Test Browser. It internally uses the low-level keyword Open browser for instantiating the respective browser and opening the Test URL.

![](https://cdn-images-1.medium.com/max/2040/0*qJ5tKK_HD2wZtETM.png)

*Close local test browser* is a high-level keyword that internally uses the *Close browser* for closing the instantiated browser.

![](https://cdn-images-1.medium.com/max/2000/0*8ZlGTInLxwThMCFT.png)

* **Tests/LocalGrid**

This folder contains two .robot files that contain the implementation of the two test scenarios. Let’s look at some of the common aspects of the test files.

    *** Settings ***
    
    
    Resource    ../../Resources/PageObject/KeyDefs/Common.robot
    Variables   ../../Resources/PageObject/Locators/Locators.py
    
    
    Test Teardown  Common.Close local test browser
    
    
    Library    BuiltIn
    
    
    *** Variables ***
    
    
    ${site_url}         https://lambdatest.github.io/sample-todo-app/
    
    
    *** Comments ***
    # Configuration for first test scenario
    
    
    *** Variables ***
    
    
    &{lt_options_1}
       ...  browserName=Chrome
    
    
    ${BROWSER_1}          ${lt_options_1['browserName']}
    
    
    *** Comments ***
    # Configuration for second test scenario
    
    
    *** Variables ***
    
    
    &{lt_options_2}
       ...  browserName=Safari
    
    
    ${BROWSER_2}          ${lt_options_2['browserName']}
    
    
    *** Test Cases ***
    
    
    Example 1: [ToDo] Parallel Testing with Robot framework
       [tags]  ToDo App Automation - 1
       [Timeout]   ${TIMEOUT}
       Open local test browser ${site_url}     ${BROWSER_1}
       Maximize Browser Window
       Sleep  3s
       Page should contain element  ${FirstItem}
       Page should contain element  ${SecondItem}
    
    
       Click button  ${FirstItem} 
       Click button  ${SecondItem}
          
       Input text  ${ToDoText}  ${NewItemText}
       Click button  ${AddButton}
       ${response}    Get Text    ${NewAdditionText}
       Should Be Equal As Strings    ${response}    ${NewItemText}
       Sleep  5s
       Log    Completed - Example 1: [ToDo] Parallel Testing with Robot framework
    
    
    Example 2: [ToDo] Parallel Testing with Robot framework
       [tags]  ToDo App Automation - 2
       [Timeout]   ${TIMEOUT}
       Open local test browser ${site_url}     ${BROWSER_2}
       Maximize Browser Window
       Sleep  3s
       Page should contain element  ${FirstItem}
       Page should contain element  ${SecondItem}
       Page should contain element  ${FifthItem}
    
    
       Click button  ${FirstItem} 
       Click button  ${SecondItem}
       Click button  ${FifthItem} 
          
       Input text  ${ToDoText}  ${NewItemText}
       Click button  ${AddButton}
       ${response}    Get Text    ${NewAdditionText}
       Should Be Equal As Strings    ${response}    ${NewItemText}
       Sleep  5s
       Log    Completed - Example 2: [ToDo] Parallel Testing with Robot framework

Since the *Test Teardown* keyword executes after every test case and test suite, we invoke the Close local test browser keyword in *Common.robot* for closing the browser instance.

![](https://cdn-images-1.medium.com/max/2040/0*l6X-sL9gO-9aDE0h.png)

Test Scenarios (1) & (2) from Test Suite 1 will be executed in parallel on Chrome & Safari browsers. Two user-defined variables, *lt_options_1* and *lt_options_2*, are used for assigning the respective browser to the *browserName* setting. In our case, they are set to Chrome and Safari respectively.

![](https://cdn-images-1.medium.com/max/2244/0*7tnHJlTytAPUN5wT.png)
>  **Discover essential tips and [agile interview question](https://www.lambdatest.com/learning-hub/agile-interview-questions?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=learning_hub) in our comprehensive tutorial. Prepare effectively and ace your next agile interview.**

The test URL is first opened using the *Open local test browser* keyword with the [test URL](https://lambdatest.github.io/sample-todo-app/) and test browser passed as input arguments. The web browser is maximized as it is considered a good Selenium practice.

![](https://cdn-images-1.medium.com/max/2244/0*GfYc__GIrKC0xv9f.png)

The *Page should contain element* keyword of *SeleniumLibrary* is used for checking the presence of the checkboxes (for first & second items) on the page. The items are checked using the *Click button* keyword in *SeleniumLibrary*.

![](https://cdn-images-1.medium.com/max/2000/0*LAeN3a6GCTvk1yLR.png)

Lastly, the *Input text* keyword is used for inputting *“Yey Let’s add it to list” *as the new item in the ToDo app. The *Add* button is clicked to add the said item to the list.

![](https://cdn-images-1.medium.com/max/2000/0*0hlUW6Wxqt6W7Llb.png)

The *Get Text* keyword in *SeleniumLibrary* returns the text value of the element identified by the below-mentioned XPath.

![](https://cdn-images-1.medium.com/max/2580/0*PUHQmUHs_RKOHDNq.png)

The *Should Be Equal As Strings* keyword in the *BuiltIn* library compares the string value assigned to *${response}* with the expected value. The test fails if both the string objects are unequal.

![](https://cdn-images-1.medium.com/max/2480/0*wkXv2SSNcAU1Qh_G.png)

    *** Settings ***
    
    
    Resource    ../../Resources/PageObject/KeyDefs/Common.robot
    Variables   ../../Resources/PageObject/Locators/Locators.py
    
    
    Test Teardown  Common.Close local test browser
    
    
    Library    BuiltIn
    
    
    *** Variables ***
    
    
    ${site_url}         https://www.lambdatest.com/selenium-playground/
    
    
    *** Comments ***
    # Configuration for first test scenario
    
    
    *** Variables ***
    
    
    &{lt_options}
       ...  browserName=Firefox
    
    
    ${BROWSER}          ${lt_options['browserName']}
    
    
    *** Test Cases ***
    
    
    Example 2: [Playground] Parallel Testing with Robot framework
       [tags]  Selenium Playground Automation
       [Timeout]   ${TIMEOUT}
       Open local test browser ${site_url}     ${BROWSER}
       Maximize Browser Window
       Page should contain element  xpath://a[.='Input Form Submit']
    
    
       Click link  ${SubmitButton}
       Page should contain element  ${Name}
       # Enter details in the input form
    
    
       # Name
       Input text  ${Name}   TestName
       # Email
       Input text  ${email}       testing@gmail.com
       # Password 
       Input text  ${passwd}       Password1
       # Company
       Input text  ${company}      LambdaTest
       # Website
       Input text  ${website}      https://wwww.lambdatest.com
       # Country
       select from list by value    ${country}     US
       # City
       Input text  ${city}       San Jose
       # Address 1
       Input text  ${address1}      Googleplex, 1600 Amphitheatre Pkwy
       # Website
       Input text  ${address2}       Mountain View, CA 94043
       # State
       Input text    ${state}          California
       # City
       Input text  ${city}       San Jose
       # Zip Code
       Input text  ${zipcode}      94088
       Sleep  5s
    
    
       Click button      ${FinalSubmission}
       Execute JavaScript    window.scrollTo(0, 0)
       Page should contain  ${SuccessText}
       Sleep  2s
    
    
       Log    Completed - Example 2: [Playground] Parallel Testing with Robot framework
>  **Here’s 295+ [Selenium Interview Questions](https://www.lambdatest.com/learning-hub/selenium-interview-questions?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=learning_hub) with Answers that will help you boost your confidence in an Interview. **

The test scenario in the above test suite is executed only on the local Firefox browser. Once the [test URL](https://lambdatest.com/selenium-playground?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=web_page) is opened using the *Open local test browser *keyword, a check is performed to validate if *Input Form Submit *is present on the page. The WebElement is located using the XPath property, and its presence is validated using *Page should contain element *keyword of *SeleniumLibrary*.

![](https://cdn-images-1.medium.com/max/3200/0*JEjQZ4GmjpiUf52T.png)

Once the click is performed, the [Input Form Demo](https://www.lambdatest.com/selenium-playground/input-form-demo?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=web_page) opens up. Here, entries in the text boxes (i.e., Name, Email, Password, etc.) are populated using the *Input text *keyword in *SeleniumLibrary*.

![](https://cdn-images-1.medium.com/max/2000/0*SzFXkeSaJuJ6QsUc.png)
>  Get started with this complete [Selenium](https://www.lambdatest.com/selenium?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=web_page) automation testing tutorial. Learn what Selenium is, its architecture, advantages and more for automated cross browser testing.

Lastly, the *select from list* by value keyword is used for selecting “US” from the country drop-down.

![](https://cdn-images-1.medium.com/max/3200/0*sBfvtlS2CGZGds8j.png)

![](https://cdn-images-1.medium.com/max/2040/0*6XMeV7-IeKxEydpm.png)

Once the inputted data is submitted by clicking the *Submit* button, the *Execute JavaScript* keyword in *SeleniumLibrary* is used for triggering a window scroll to the start of the page. The keyword’s functionality is very much similar to that of [JavaScriptExecutor in Selenium WebDriver](https://www.lambdatest.com/blog/how-to-use-javascriptexecutor-in-selenium-webdriver/?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=blog)!

![](https://cdn-images-1.medium.com/max/2000/0*Hy8VV0fqlFlidlua.png)

Finally, the presence of the text “*Thanks for contacting us, we will get back to you shortly*.” is checked to verify if the page submission was successful.

![](https://cdn-images-1.medium.com/max/3200/0*zbroKep71pJNJYvX.png)
>  **A comprehensive[ Acceptance Testing ](https://www.lambdatest.com/learning-hub/user-acceptance-testing?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=learning_hub)(UAT) tutorial that covers what User Acceptance Testing is, its importance, benefits, and how to perform it with real-time examples.**

⚡💡*SeleniumLibrary* is not thread-safe; hence there is no safety-net for concurrent access to browser instances or parallel test execution across multiple threads.

Pabot runner eliminates the thread-safety issue, as parallelism is done at the process-level (not the thread-level). Each process in Pabot has its own memory space, due to which parallel processes can run in isolation without interfering with each other!

## Execution

Before using the Robot framework for parallel test execution, let’s run the same tests sequentially. This is to benchmark the test execution time (or performance) when the same test scenarios are run in parallel using Pabot runner.

Please clone the repo in case you have not done the same. After completing the steps mentioned in the *Project Prerequisites* section of this blog on using the Robot framework for parallel test execution.

**Serial Test Execution (Purpose: Benchmarking)**

Invoke the following command to run the test scenarios located in *Tests/LocalGrid* folder serially.

It is essential to note that the time taken for execution also depends on factors like machine performance, browser performance, network connectivity, and more. Hence, the numbers being showcased might vary depending on the factors mentioned above.

    robot Tests/LocalGrid/

![](https://cdn-images-1.medium.com/max/3004/0*AUk2RP6mldGC0hZa.png)
>  **A comprehensive [Exploratory Testing](https://www.lambdatest.com/learning-hub/exploratory-testing?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=learning_hub) tutorial that covers what Exploratory Testing is, its importance, benefits, and how to perform it with real-time examples.**

As seen in the Test Report, the serial test execution of three test scenarios took around *50 seconds* on my machine (i.e., MacBook Pro, 2 GHz Quad-Core Intel Core i5 processor).

![](https://cdn-images-1.medium.com/max/3200/0*4OhloKvx3tfSvhdy.png)

Let’s see what happens when the tests and/or test suites are run in parallel using Pabot runner.

**Parallel Test Execution (Default: Suite-Level)**

By default, Pabot splits the test execution at the test-suite level, with each process running a separate suite. Tests inside a test-suite (i.e., *.robot file) run in series, whereas the suites run in parallel.

In our case, we have two test-suites where *test_todo_app.robot* consists of two test scenarios, whereas *test_sel_playground.robot* consists of a single test scenario.

![](https://cdn-images-1.medium.com/max/2000/0*4ynsGejYtQy3qZmC.png)

Invoke the following command on the terminal to run Robot test suites in parallel using Pabot.

    pabot — verbose — outputdir results — log local_test_parallel_log.html — report local_test_parallel_report.html Tests/LocalGrid/

*–* *–verbose* : Increase the verbosity level
*–* *–outputdir* : Specify the directory used for storing the results
*–* *–log* : Name of the log file generated post test execution
*–* *–report* : Name of the report file (in specified format) generated post test execution

Shown below is the execution snapshot which indicates the test execution was successful:

![](https://cdn-images-1.medium.com/max/3200/0*JcB1ADkVG1DNX3DV.png)
>  **A comprehensive [UI testing ](https://www.lambdatest.com/learning-hub/ui-testing?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=learning_hub)tutorial that covers what UI testing is, its importance, benefits, and how to perform it with real-time examples.**

Here are some interesting things to notice from the test execution:

* Test suites are executing in parallel, with each process (PID: 78954 and PID:78955) running a separate suite

* A file named *.pabotsuitenames* is auto-generated during the phase of test execution. It contains information related to test suites when they are executed in parallel.

*FileName — .pabotsuitenames*

![](https://cdn-images-1.medium.com/max/2336/0*UZ1Se32_ilCjlR_o.png)

* The total test execution time has come down from *50 seconds *(with serial execution) to *23 seconds* (with suite-level parallelism).

![](https://cdn-images-1.medium.com/max/3200/0*CEMEAcvdPkH4Lsjo.png)
>  **In this [Appium ](https://www.lambdatest.com/appium?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=web_page)tutorial, learn about Appium and its benefits for mobile automation testing. Take a look at how Appium works and see how to perform Appium testing of your mobile applications.**

In a nutshell, suite-level parallelism with Pabot provided ~50 percent savings in test execution time!

**Parallel Test Execution (Test-Level)**

Pabot lets you achieve parallel execution at test-level through the *–testlevelsplit* option. In case *.pabotsuitenames* contains both tests and test-suites, then *–testlevelsplit* will only affect new suites and split only them.

Here, each process runs a single test case. For instance, if the test suite(s) have four tests *(e.g. T1, T2, T3, T4)*, then four separate processes *(P1, P2, P3, P4)* will run each test in parallel. Test-level parallelism must be preferred over suite-level parallelism in cases where suite(s) have a large number of *independent* tests that can run concurrently.

In our case, there are three test scenarios that can run in parallel.

![](https://cdn-images-1.medium.com/max/2376/0*u75WLUvbuCdOASLP.png)

![](https://cdn-images-1.medium.com/max/2680/0*F6T5qg-E65I3TFXY.png)

Invoke the following command on the terminal to run individual tests in parallel using Pabot.

    pabot — verbose — testlevelsplit — outputdir results — log local_test_parallel_log.html — report local_test_parallel_report.html Tests/LocalGrid/

Since there are three tests in total, three parallel processes are invoked with each running a single test. As seen in the test execution screenshot, three parallel processes (PID: 92660, 92661, and 92662) handle one test scenario each.

![](https://cdn-images-1.medium.com/max/3200/0*3PJlMtoepEiCV7vI.png)

The total test execution time has come down from *50 seconds* (with serial execution) and *23 seconds* (with suite-level parallelism) to *14 seconds* (with test-level parallelism).

![](https://cdn-images-1.medium.com/max/3200/0*RFRtFNPjiid60dvX.png)

It is important to note that the total execution time might vary from one run to another. For instance, subsequent runs (with the same load conditions) resulted in *16 seconds & 17 seconds*, respectively.

**Customize Number of Parallel Executors**

There are scenarios where you might want to invoke more/less parallel executors to achieve more out of parallelism with the Robot framework. This is where the *–processes* option lets you customize the number of parallel executors for test case execution. It is recommended to take the available resources (physical CPU cores, memory, etc.) into account when customizing the number of parallel executors.

    pabot — processes <num_parallel_processes>

Let’s do a test split execution with 2 parallel processes and see the difference. Invoke the following command on the terminal:

    pabot — verbose — testlevelsplit — processes 2 — outputdir results — log local_test_parallel_log.html — report local_test_parallel_report.html Tests/LocalGrid/

As seen from the execution snapshot and test report, the total test execution time is *25 seconds* (i.e., same as test-suite level execution). However, the execution time might vary from one test run to another.

![](https://cdn-images-1.medium.com/max/3200/0*bTGR23oPjwehfeNE.png)

![](https://cdn-images-1.medium.com/max/3200/0*jfuSxNVx7okEF5iU.png)

To summarize, both thread-level and suite-level parallelism can potentially accelerate test execution time. However, you must keep a watchful eye on test dependencies and available resources (i.e., CPU cores, memory, etc.) to avoid conflicts or flaky tests (or unexpected results).

## Parallel Testing using Pabot on Cloud Grid

So far, we have demonstrated using the Robot framework for parallel test execution with Pabot on the local machine (macOS Ventura). So far, so good 🙂However, a challenge arises if tests have to be performed on different platforms and browser combinations. What if we have to execute the tests mentioned above on the latest and/or older version of Chrome, Firefox, etc., installed on Windows 10 and Windows 11 machines?

In such cases, we can leverage the [benefits of cloud testing](https://www.lambdatest.com/blog/benefits-of-cloud-testing/#WATB?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=blog) as it helps in executing automated UI tests at scale reliably and securely. With the rapid proliferation of cloud technologies, it is imperative to lean on [cloud testing](https://www.lambdatest.com/blog/benefits-of-cloud-testing/#WICT?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=blog) to realize:

* Reduced infrastructure costs

* Better [test coverage](https://www.lambdatest.com/learning-hub/test-coverage?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=learning_hub)

* Shortened developer feedback

* Improved product quality

In this section of the [Selenium Python testing](https://www.lambdatest.com/selenium-python-testing?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=web_page) tutorial using Robot framework, we will demonstrate how to port the existing Robot tests so that it runs on LambdaTest cloud grid. LambdaTest is a cloud-based digital experience testing platform that lets you run [Selenium automation tests with Robot](https://www.lambdatest.com/selenium-automation-testing-with-robot-framework?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=web_page) on 3,000+ browsers and operating systems online!
{% youtube SqQ8SugRDos %}
You can also Subscribe to the [LambdaTest YouTube Channel ](https://www.youtube.com/channel/UCCymWVaTozpEng_ep0mdUyw?sub_confirmation=1?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=video)and stay updated with the latest tutorials around [automation testing](https://www.lambdatest.com/automation-testing?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=web_page), [Selenium testing](https://www.lambdatest.com/selenium-automation?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=web_page), [Cypress](https://www.lambdatest.com/learning-hub/cypress-tutorial?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=learning_hub), CI/CD, and more.

Visit our support documentation to [get started with Selenium Python testing.](https://www.lambdatest.com/support/docs/python-with-selenium-running-python-automation-scripts-on-lambdatest-selenium-grid/?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=support_doc)

To get started, you need to create an account on LambdaTest. Post that, please make a note of your username and access key, which are available in the [LambdaTest Profile](https://accounts.lambdatest.com/detail/profile?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=web_page) section.

![](https://cdn-images-1.medium.com/max/3200/0*pLeJdZL8e5jtHPL4.png)

Now export the environment variables *LT_USERNAME* and *LT_ACCESS_KEY*, as they are required for running tests on LambdaTest.

![](https://cdn-images-1.medium.com/max/3200/0*or5QT9FrmrvhU293.png)

**Project Setup**

*Prerequisites* and *Project setup* remain almost the same as shown in the ‘Parallel Testing Demonstration’ earlier. The only difference is that the ported tests are located in the *Tests/CloudGrid* folder.

![](https://cdn-images-1.medium.com/max/2000/0*s5Cy5jQOQdwEKovc.png)

## Implementation (Porting Changes for Execution on Cloud Grid)

As the first step, we copy the relevant capabilities from the [LambdaTest Capabilities Generator.](https://www.lambdatest.com/capabilities-generator/?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=web_page) Since *SeleniumLibrary *is compatible with [Selenium 4,](https://www.lambdatest.com/learning-hub/selenium-4?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=learning_hub) we choose the capabilities for Python with Selenium 4. Though there is no separate mention of *Robot* in the *‘Select your framework’*, you can still use the capabilities-related nomenclature in the implementation.

![](https://cdn-images-1.medium.com/max/3200/0*JIJotwSAJkOakQt_.png)

For instance, you can use the following when setting the capabilities (all in String format):
<table>
    <tr>
        <td>CAPABILITIES (SELENIUM 4)</td>
        <td>SAMPLE VALUES</td>
    </tr>
    <tr>
        <td>platformName</td>
        <td>Windows 11, MacOS Ventura, etc.</td>
    </tr>
    <tr>
        <td>browserName</td>
        <td>Chrome, Firefox, Safari, etc.</td>
    </tr>
    <tr>
        <td>browserVersion</td>
        <td>String value based on the browser used for testing</td>
    </tr>
    <tr>
        <td>w3c</td>
        <td>True (when tests are executed using Selenium 4)</td>
    </tr>
    <tr>
        <td>Name (optional)</td>
        <td>Test name</td>
    </tr>
    <tr>
        <td>Build (optional)</td>
        <td>Build name</td>
    </tr>
    <tr>
        <td>Project (optional)</td>
        <td>Project name</td>
    </tr>
</table>
The first test scenario (for ToDo app) is to be tested on Chrome (latest version) on Windows 11. Shown below are the capabilities:

*FileName — Tests/CloudGrid/test_todo_app.robot*

![](https://cdn-images-1.medium.com/max/3052/0*H95rnwMmL4T-G7uO.png)

*Capabilities for Test Scenario — 1 (Test Suite — 1)*

![](https://cdn-images-1.medium.com/max/3052/0*ABKXkviequm6ZJfY.png)

*Capabilities for Test Scenario — 2 (Test Suite — 1)*

On similar lines, we updated the capabilities for browser & combinations used in Test Scenario — 1 (of Test Suite — 2).

![](https://cdn-images-1.medium.com/max/3152/0*PwI3s6c7EgV6fJb9.png)

*Capabilities for Test Scenario — 1 (Test Suite — 2)*

We have added a few *Variables* and *High-level keywords* that will be used for opening test browser(s) on the desired operating system (or platform).

*FileName — Resources/PageObject/KeyDefs/Common.robot*

![](https://cdn-images-1.medium.com/max/3200/0*cF7BJxQWJmfJE9I1.png)

*${REMOTE_URL}* is the LambdaTest Hub address which will be further used by the *Open Browser* keyword in Robot to open the desired *browser* (e.g., Chrome) on the respective platform (e.g., Windows 11).

![](https://cdn-images-1.medium.com/max/2964/0*0CX7riIDvIm9Cvph.png)

[*Image Source](https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html#Open%20Browser)*

Two high-level keywords are created for opening and terminating the browser instance instantiated on the desired platform (or OS). *LambdaTest Hub URL* and *Desired Capabilities* are passed as parameters to the low-level keyword *Open browser*.

*FileName — Resources/PageObject/KeyDefs/Common.robot*

![](https://cdn-images-1.medium.com/max/2748/0*PYzPF4EyOEUYFNvy.png)

*High-level keyword: Open test browser*

![](https://cdn-images-1.medium.com/max/2000/0*bXRiH76i_1l88bOw.png)

*High-level keyword: Close test browser*

Now that the infrastructure-level settings are all done, let’s look at the changes in the test logic (*in Tests/CloudGrid/test_sel_playground.robot)*.

**Step 1 (Addition of Grid URL and Capabilities)**

As mentioned earlier, we first add the desired capabilities comprising of the remote browser, version, and user-defined capabilities (i.e. Project name, Test name, etc.) for LambdaTest.

![](https://cdn-images-1.medium.com/max/3152/0*Xi-kZD0Aw0Ka3wWw.png)

**Step 2 (Open Test Browser on Test OS )**

The high-level keyword Open *test browser* which accepts three parameters — *Test URL, Browser, and Desired Capabilities.*

![](https://cdn-images-1.medium.com/max/2884/0*CRFluMc5UAZdItPM.png)

There is no change in the core test logic, except that *Close test browser* high-level keyword is used for closing the instantiated browser instance.

![](https://cdn-images-1.medium.com/max/2000/0*nzUl-kT4TdRQMGn9.png)

## Execution

Before execution, set the environment variables *LT_USERNAME* and *LT_ACCESS_KEY* on the terminal. You can find the same in the LambdaTest Profile section.

![](https://cdn-images-1.medium.com/max/3200/0*oFYluNVBtLFz7E1T.png)

**macOS/Linux**

    export LT_USERNAME="YOUR_LAMBDATEST_USERNAME"
    export LT_ACCESS_KEY="YOUR_LAMBDATEST_ACCESS_KEY"

**Windows**

    set LT_USERNAME="YOUR_LAMBDATEST_USERNAME"
    set LT_ACCESS_KEY="YOUR_LAMBDATEST_ACCESS_KEY"

Now that the environment variables are set, invoke the following command on the terminal to run individual tests in parallel (on LambdaTest Grid) using Pabot.

    pabot — verbose — testlevelsplit — outputdir results — log cloud_test_parallel_log.html — report cloud_test_parallel_report.html Tests/CloudGrid/

The above command will kick-start three processes, each of which runs a test scenario (or test case) in parallel. Shown below is the terminal and LambdaTest dashboard screenshot(s) that indicates that the parallel execution resulted in Success. 🚀

![](https://cdn-images-1.medium.com/max/3200/0*JRROgZdD37ZbxyY0.png)

![](https://cdn-images-1.medium.com/max/3200/0*xY9tQhKLIZD2J2LS.png)

*Execution in Progress*

![](https://cdn-images-1.medium.com/max/3200/0*EHqQLKGfano3KxzH.png)

*Completion of Execution*

![](https://cdn-images-1.medium.com/max/3200/0*zs6nqjic7_WSXPDp.png)

*Video Grab of Test Execution*

With this, we have successfully used the Robot framework for parallel test execution with Pabot on the local grid and LambdaTest cloud grid. Testing Cloud with Robot framework can be leveraged when you want to run tests at scale in continuous CI/CD pipelines!

Are you enthusiastic about becoming proficient in [Python automation testing?](https://www.lambdatest.com/python-automation-testing?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=web_page) Opting for a [Selenium Python 101 certification](https://www.lambdatest.com/certifications/selenium-python-101?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=certification) program is an excellent choice to kickstart your path towards becoming an automation testing specialist and improving your Python abilities. Enrolling in this program will provide you with a solid groundwork for effectively utilizing Selenium Python in your testing projects, helping you excel in your automation testing journey.

In addition, you can also refer to our [Robot framework interview questions and answers](https://www.lambdatest.com/learning-hub/robot-framework-interview-questions?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=learning_hub) in case you are preparing for the interview or looking to expand your knowledge on Robot framework.
>  **[WebDriver](https://www.lambdatest.com/learning-hub/webdriver?utm_source=devto&utm_medium=organic&utm_campaign=jun_26&utm_term=bh&utm_content=learning_hub) is a remote programming interface that can be used to control, or drive, a browser either locally or on a remote machine. Learn more in this complete Selenium WebDriver Tutorial.**

## It’s a Wrap

Thanks for getting this far! Though the Robot framework supports sequential test execution (out-of-the-box), tests can be run in parallel by leveraging the Pabot test runner. Pabot lets you parallelize test-suites as well as tests, that too without major code modifications.

As we all know, excessive parallelism can cause test flakiness if the tests are not designed to handle concurrent execution. It becomes essential to follow Selenium’s best practices when opting for parallel test execution. You can also leverage the benefits of a cloud grid like LambdaTest in case you are looking to capitalize on the benefits of cloud testing and continuous integration.

Until next time, happy testing!

## Frequently Asked Questions (FAQs)

### Does Robot Framework support parallel execution?

Yes, Robot Framework does support parallel execution. Starting from version 3.2, Robot Framework introduced native support for parallel test execution.

To enable parallel execution in Robot Framework, you can use the *–parallel* command-line option or the *–processes* option to specify the number of parallel processes to use.