How to run parameterized Robot Framework tests in Jenkins

HOME

When running your Jenkins automation jobs, you may need to pass some parameters to your scripts. These parameters can be a URL, a browser name, or even the test user’s credentials. This tutorial will walk you through the process of creating a parameterized Jenkins job for Robot Framework.

It is recommended to go through these tutorials, before creating a parameterized Jenkins job:-

Download and install Jenkins on Windows10

Configure JAVA_HOME and MAVEN_HOME

Types of parameters

Jenkins supports several parameter types. Below is a list of the most common ones, but keep in mind that different plugins may add new parameter types:

  • String: any combination of characters and numbers
  • Choice: a pre-defined set of strings from which a user can pick a value
  • Credentials: a pre-defined Jenkins credential
  • File: the full path to a file on the filesystem
  • Multi-line String: same as String, but allows newline characters
  • Password: similar to the Credentials type, but allows us to pass a plain text parameter specific to the job or pipeline
  • Run: an absolute URL to a single run of another job

Implementation Steps

Step 1: Create a new FreeStyle project

  1. Give the Name of the project – RobotFramework_Demo.
  2. Click on the FreeStyle project. 
  3. Click on the OK button.

Step 2: Description of the project

In the General section, enter the project description in the Description box.

Check the option – This project is parameterized.

Click on Add Parameter, and we can select any option as shown in the above image.

Step 3: Select the Choice Parameter

Choice Parameter

As I want to run my tests on different browsers, I have selected Choice Parameter.

  1. Give the Name of the Parameter.
  2. Give the Choices of the Parameter – Chrome, Firefox, IE
  3. Give the Description of the Parameter – Select any browser to run the tests (optional).

Step 4: Select a custom workspace

Mention the full path of the project in the Use custom workspace.

Step 5: Source Code Management

In the Source Code Management section, select None.

Step 6: Build Management

Go to the Build section of the new job. Select “Execute Windows batch command”.

Mention the command needed to execute the tests. In this case, I have to execute all the tests, so used the below command:

robot --variable browser_name:"%browserName%" --include "%Tags%" .

Step 7: Select “HTML Reports” from “Post Build Actions

Scroll down to Post Build Actions” and click on the “Add Post Build Actions” drop-down list.

Select “Publish HTML Reports“. 

Enter the HTML directory to archive – Empty, Index page[s] – report.html, and Report title – HTML Report.

Click on the Apply and Save buttons.

If you want to see where the report is saved in Jenkins, go to the Dashboard -> RobotFramework_Demo -> Workspace -> report.html.

We have created a new project “RobotFramework_Demo“.

Step 8: Execute the tests

Let’s execute it now by clicking on the “Build with Parameters” button.

This screen contains the parameters which we have to select. The browser was a choice parameter and selecting a parameter from it and Tags was also a Choice parameter, so mention the tags in it and click on the “Build” button.

Right-click on Build Number (here in my case it is #11).

Click on Console Output to see the result.

Step 9: View the HTML Report

Once the execution is completed, click on go “Back to Project“, and we could see a link to view the “HTML Report“.

Click on the HTML Report. It displays the summary of the tests.

Congratulations on making it through this tutorial and hope you found it useful! Happy Learning!! Cheers!!

Additional Tutorials

How to Install Python on Windows 11
How to install and setup Robot Framework for Python
How to rerun failed tests in Robot Framework
Page Object Model in the Robot Framework
 How to set variable values from Runtime command in Robot Framework
How to load data from CSV files in the Robot Framework?

Robot Framework Tutorials

HOME

Robot Framework is a generic open-source automation framework. It can be used for test automation and robotic process automation (RPA). RPA is extensively used for Web Application Automation, API Automation, RPA, and Database Testing.

Robot Framework has an easy syntax, utilizing human-readable keywords. Its capabilities can be extended by libraries implemented with Python, Java, or many other programming languages.

Chapter 1 Robot Framework Features – Settings, Libraries, Variables, Keywords, Resources, Reports, Logs
Chapter 2 What are variables in Robot Framework?
Chapter 3 How to handle text box in Robot Framework
Chapter 4 How to handle radio buttons in Robot Framework
Chapter 5 How to handle checkbox in Robot Framework
Chapter 6 How to handle dropdowns in Robot Framework
Chapter 7 How to handle multiple windows in Robot Framework
Chapter 8 How to handle alerts in Robot Framework
Chapter 9 What is Resource File in Robot Framework 
Chapter 10 How to run all the tests from the folder in Robot Framework
Chapter 11 How to implement tagging in Robot Framework
Chapter 12 How to rerun failed tests in Robot Framework
Chapter 13 How to use Drag and Drop in Robot Framework?
Chapter 14 How to set variable values from Runtime command in Robot Framework
Chapter 15 Page Object Model in Robot Framework with Selenium and Python
Chapter 16 Parallel Testing in Robot Framework
Chapter 17 How to write tests in Robot Framework in BDD Format

Data-Driven Testing

Chapter 1 Data-Driven Testing in Robot Framework 
Chapter 2 How to load data from CSV files in the Robot Framework?

API Testing

Chapter 1 How to perform API Testing in Robot Framework using RequestLibrary
Chapter 2 How to Implement Basic Auth in Robot Framework – NEW
Chapter 3 How to pass authorization token in header in Robot Framework – NEW
Chapter 4 Verifying Status Code and Status Line in Robot Framework – NEW

CI/CD

Chapter 1 Run Robot Framework Tests in GitLab CI/CD
Chapter 2How to run Robot Framework in GitHub Actions

Jenkins

Chapter 1 How to integrate Robot Framework with Jenkins
Chapter 2 How to run parameterized Robot Framework tests in Jenkins

How to run parameterized Selenium tests in Jenkins

HOME

When running your Jenkins automation jobs, you may need to pass some parameters to your scripts. These parameters can be a URL, a browser name, or even the test user’s credentials. This tutorial will walk you through the process of creating a parameterized Jenkins job.

  1. Types of parameters
  2. Implementation Steps
    1. Step 1: Create a new project using the Maven project plugin
    2. Step 2: Description of the project
      1. Choice Parameter
      2. String Parameter
    3. Step 3: Source Code Management
    4. Step 4: Build Management
    5. Step 5: Select “TestNG Reports” from “Post Build Actions”
    6. Step 6: Execute the tests
    7. Step 7: View the TestNG Report

    It is recommended to go through these tutorials, before creating a parameterized Jenkins job:-

    Download and install Jenkins on Windows10

    Configure JAVA_HOME and MAVEN_HOME

    Types of parameters

    Jenkins supports several parameter types. Below is a list of the most common ones, but keep in mind that different plugins may add new parameter types:

    • String: any combination of characters and numbers
    • Choice: a pre-defined set of strings from which a user can pick a value
    • Credentials: a pre-defined Jenkins credential
    • File: the full path to a file on the filesystem
    • Multi-line String: same as String, but allows newline characters
    • Password: similar to the Credentials type, but allows us to pass a plain text parameter specific to the job or pipeline
    • Run: an absolute URL to a single run of another job

    Implementation Steps

    Step 1: Create a new project using the Maven project plugin

    1. Give the Name of the project.
    2. Click on the Maven project. 
    3. Click on the OK button.

    Step 2: Description of the project

    In the General section, enter the project description in the Description box.

    Check the option – This project is parameterized.

    Click on Add Parameter and we can select any option as shown in the above image.

    Choice Parameter

    As I want to run my tests on different browsers, I have selected Choice Parameter.

    1. Give the Name of the Parameter.
    2. Give the Choices of the Parameter – chrome, firefox
    3. Give the Description of the Parameter – Please select the browser for the test execution.

    String Parameter

    I want to pass the test environment URL in the test. So, I’m selecting a string value. Select String Parameter on the Add Parameter menu.

    1. Give the Name of the Parameter.
    2. Give the Default Value of the Parameter. This value will be used if nothing will be provided.
    3. Give the Description of the Parameter – Provide the environment URL.

    Step 3: Source Code Management

    In the Source Code Management section, select None.

    Step 4: Build Management

    Go to the Build section of the new job.

    1. In the Root POM textbox, enter the full path to pom.xml
    2. In the Goals and Options section, enter the below command:
    clean test -Dbrowser=$browser -Durl=$URL
    

    Step 5: Select “TestNG Reports” from “Post Build Actions”

    Scroll down to Post Build Actions” and click on the “Add Post Build Actions” drop-down list.

    Select “Publish TestNG Results“. 

    Enter the TestNG XML Report Pattern as “**/testng-results.xml” and click on the “Save” button.

    Click on the Apply and Save buttons.

    We have created a new project SeleniumParameterizedTests” with the configuration to run TestNG Tests and also to generate TestNG Reports after execution using Jenkins.

    Step 6: Execute the tests

    Let’s execute it now by clicking on the “Build with Parameters” button.

    This screen contains the parameters which we have to select. The browser was a choice parameter and select a parameter from it and URL was a String parameter, so mention the URL in it and click on the “Build” button.

    Right-click on Build Number (here in my case it is #1).

    Click on Console Output to see the result.

    Step 7: View the TestNG Report

    Once the execution is completed, click on go “Back to Project“, and we could see a link to view the “TestNG Report“.

    Click on the TestNG Results. It displays the summary of the tests.

    Congratulations on making it through this tutorial and hope you found it useful! Happy Learning!! Cheers!!

    Additional Tutorials

    Jenkins GitLab Integration
    How to Schedule a Jenkins Job
    How to create Jenkins pipeline for Serenity tests
    Integration of Cucumber Report with TestNG in Jenkins
    How to create Jenkins pipeline for Gradle project
    How to run parameterized Selenium tests in Jenkins