Robotic Process Automation (RPA) with Selenium

This tutorial will demonstrate how to use Step and Selenium to automate various browser tasks.

Get Step SaaS for free to follow this tutorial
Illustration for Robotic Process Automation (RPA) with Selenium

This tutorial will demonstrate how to use Step and Selenium to automate various browser tasks. In this example, we will be automating an update to the inventory of a Demo online shop running at https://opencart-prf.exense.ch/admin/.

This is a technical tutorial intended for users who are already familiar with RPA and Selenium.

Prerequisites

  • Step: You can either install Step Enterprise or OS following the quick setup guide or get a SaaS instance up and running in minutes. For most users the SaaS option is recommended, you can get it easily up and running on stepcloud.ch.
  • Git
  • Maven 2 or higher
  • JDK 11 or higher
  • (optional) The Chrome browser
  • (optional) ChromeDriver, for automating a browser

Hint: The optional software is recommended to follow the local parts of this tutorial. You can skip all steps requiring ChromeDriver and still finish the tutorial if you are only following the SaaS solution.

Preparing the sample project

We have prepared a sample project that will be used throughout this tutorial which uses Selenium to automate interactions with a test environment called OpenCart that is provided by us.

1. Get the code

The project is available on GitHub; to clone it using git, run:

  git clone https://github.com/exense/step-tutorials.git
  

2. (optional) Run tests locally

To see the interactions that are performed, run the JUnit tests:

  cd [step-tutorials-folder]/step-selenium-tutorials

# If ChromeDriver is installed system-wide and added to the path:
mvn clean compile test

# Otherwise, explicitly specify the ChromeDriver path:
mvn clean compile test -Dwebdriver.chrome.driver=c:/tools/chromedriver/chromedriver.exe
  

The test cases navigate through the “Desktop” and “Components” categories of the website as a client and update the products quantities as an admin, as defined in the unit tests.

3. Check the source code

Take a moment to look at the sample project code – we tried to keep it as simple and straightforward as possible. You can find it in the sample project folder under:

4. Create a keyword package

To package the functionality in a jar file, run:

  cd [step-tutorial-folder]/step-selenium-tutorials
mvn clean package -DskipTests
  

This creates a file, named step-selenium-tutorials-0.0.0.jar, in the “target” folder of the project directory. This is the file that we will use in the subsequent steps.

Publish your keywords to Step

1. Switch to your Step instance

If you have access to an existing Step instance (on-premise or cloud), access it and log in, see prerequisites if not. Remember that for on-premise setup Chrome and Chromedriver must be available on the Step’s agents.

2. Import the keyword package

Step has a special view for managing Keywords. This screenshot shows the Keywords view with the Upload Package dialog open as a reference for the next steps.

  1. Navigate to Keywords
  2. Click the Upload Package button
  3. Select the step-selenium-tutorials-0.0.0.jar as the package file.
    Hint: Make sure you selected the correct file. If successful you will see two keywords listed.
  4. Click Save to do the import

Define the Robotic Process Automation (RPA)

For the purposes of this tutorial, we will use Step to automate the process of updating the inventory of an online shop. Therefore we need to set up a “Plan”, in which we define which steps should be executed to perform the inventory update. Simply put, we want to automate a browser that logs in to the OpenCart web shop and updates the quantities of some of the products we have specified in a CSV file.

1. Create a new Plan

  1. Navigate to Plans
  2. Click + to create a new plan
  3. Enter a name
  4. Select “TestCase” as a Template
  5. Click Save and edit

2. How to configure the Plan

The visual editor is the main tool to create and edit plans in Step. We will use this to create the RPA, so get familiar with the UI explained in this screenshot:

3. Add the Login-Keyword to the new Plan

In order to define what our plan is going to do, we have to add and configure our already imported keywords to it. First of all we want to tell STEP to log in to OpenCart. Therefore we add the keyword “Opencart RPA Testcase - Admin Login”.

  1. Click on “Keywords” to open a list of available keywords
  2. Find the Keyword “Opencart RPA Testcase - Admin Login” and click its + button to add it to the plan
  3. Click on the newly imported keyword
  4. Configure the login step: fill “true” in the “headless” field
  5. Fill in “demo” as username
  6. Fill in “demo” as password

4. Add and configure the ForEach-Control

As we want to modify a bunch of products on the basis of a CSV file, we need to define a loop and iterate over the CSV data.

At the tree-view on the left, click on the name of the plan, in our case “Update-Demo-Inventory”

  1. Select the root element of your plan
  2. Select “Controls”
  3. Find the “ForEach” control and click the + button to add it to the plan
  4. As “Source Type” choose “CSV”
  5. Drag and drop or use the file chooser to choose the prepared CSV file:

5. Loop the Update-Product-Keyword

  1. Select “Keywords”
  2. Find the “Update Product” Keyword and click its plus button to add it to the loop.
  3. In the “product” field, type “row.Product”. Note that “row” refers to each row in the CSV and “Product” is the name of the first column.
  4. Mark that field as “dynamic” by activating the button with the lightning icon.
  5. In the “quantity” field, type “row.Quantity”.
  6. Finally, mark that field as “dynamic” as well by activating the button with the lightning icon.

6. Run the Automation and check results

To run the RPA, simply click the start execution button (play icon) on top of the plan and confirm by clicking it in the dialog again. This will update the inventory according to the changes listed in the CSV file.

You now know how to automate tasks using Step and Selenium, and can use this to greatly improve the work efficiency of your business.

Note: To keep the OpenCart instance clean for everyone doing this tutorial the changes will not be saved in the OpenCart instance

7. Check the status of your executions on the “Executions” tab

The execution automatically opens, you can continue using Step and go to Executions in the menu and click on an individual execution to get a detailed view of that execution to open it again.

Hint: This can be done at any time, including when an execution is currently running

Status of a successfully finished execution
Illustration for Using Step with Grafana
Using Step with Grafana

This article demonstrates how to connect Grafana to data generated by Step.

Illustration for Setting up system monitoring with a Step agent
Setting up system monitoring with a Step agent

This article demonstrates how to set up distributed system monitoring using Keyword executions, and analyze the results as measurements.

Illustration for NET tutorials: Microsoft Office automation with Step
NET tutorials: Microsoft Office automation with Step

This tutorial demonstrates how to automate interaction with Microsoft Office applications using the Office Interop Assembly.

Illustration for JUnit Plan Runner
JUnit Plan Runner

This article provides documentation for how to integrate JUnit tests into Step.

Illustration for How to monitor services availability and performance
How to monitor services availability and performance

This tutorial demonstrates how Step can be used to monitor services, availability and performance metrics.

Illustration for .NET tutorials: AutoIt with Step
.NET tutorials: AutoIt with Step

This tutorial demonstrates how to utilize the AutoIt C# binding to automate interactions with Windows applications.

Illustration for Android Testing using Step and Appium
Android Testing using Step and Appium

This article demonstrates the automation of mobile applications on Android using the Appium framework.

Illustration for Browser-based automation with Step and Selenium
Browser-based automation with Step and Selenium

This article defines three Keywords which will be used in browser-based automation scenarios, using Step and Selenium, as general drivers.

Illustration for Load Testing with Cypress
Load Testing with Cypress - advanced

This tutorial shows you how to efficiently set up a browser-based load test using existing Cypress tests in the Step automation platform.

Illustration for Adding and Configuring New Agents
Adding and Configuring New Agents

In this short tutorial, we show how to quickly implement a simple browser-based load test based on Cypress scripts in Step.

Illustration for Load Testing with Playwright
Load Testing with Playwright - advanced

This tutorial shows you how to efficiently set up a browser-based load test using existing Playwright tests in the Step automation platform.

Illustration for Basic Keyword Development
Basic Keyword Development

This article explains Keywords in Step and demonstrates how to create simple ones.

Illustration for Designing functional tests
Designing functional tests

This tutorial demonstrates the design, execution, and analysis of functional tests using the web interface of Step.

Illustration for Robotic Process Automation (RPA) with Cypress
Robotic Process Automation (RPA) with Cypress

This tutorial demonstrates how to use Step and Cypress to automate various browser tasks.

Illustration for Synthetic Monitoring with Selenium
Synthetic Monitoring with Selenium

This tutorial demonstrates how Selenium automation tests can be turned into full synthetic monitoring using Step.

Illustration for Load Testing with Cypress
Load Testing with Cypress

In this tutorial, we'll show you how to easily set up and run a browser-based load test with Step's wizard, using your existing Cypress tests, on the Step automation platform.

Illustration for Load Testing with Selenium
Load Testing with Selenium

This tutorial shows you how to efficiently set up a browser-based load test using existing Selenium tests in the Step automation platform.

Illustration for Synthetic Monitoring with Playwright
Synthetic Monitoring with Playwright

This tutorial demonstrates how Playwright automation tests can be turned into full synthetic monitoring using Step.

Illustration for Synthetic Monitoring with Cypress
Synthetic Monitoring with Cypress

This tutorial demonstrates how Cypress automation tests can be turned into full synthetic monitoring using Step.

Illustration for Robotic Process Automation (RPA) with Playwright
Robotic Process Automation (RPA) with Playwright

This tutorial will demonstrate how to use Step and Playwright to automate various browser tasks.

Illustration for Load Testing with Playwright
Load Testing with Playwright

In this tutorial, we'll show you how to easily set up and run a browser-based load test with Step's wizard, using your existing Playwright tests, on the Step automation platform.

Illustration grafana devops tutorial
Continuous load testing with K6

Quickly integrate K6 based load-tests in your DevOps workflow

Illustration for playwright synthetic monitoring in a devops workflow
DevOps Synthetic Monitoring with Playwright - Advanced

This tutorial demonstrates how Playwright tests can be reused for synthetic monitoring of a productive environment in a DevOps workflow

Illustration for playwright synthetic monitoring in a devops workflow
DevOps Synthetic Monitoring with Playwright

This tutorial demonstrates how Playwright tests can be reused for synthetic monitoring of a productive environment in a DevOps workflow

Illustration for okhttp devops
Protocol-based load testing with okhttp

In this tutorial you'll learn how to quickly set up a protocol-based load test with okhttp

Illustration for playwright devops
Continuous end-to-end testing

Learn how to set up continuous end-to-end testing across several applications based on Playwright tests in your DevOps pipeline using Step

Illustration for playwright devops
Continuous load testing with Playwright

Learn how to quickly set up continuous browser-based load testing using Playwright tests in your DevOps pipeline

Want to hear our latest updates about automation?

Don't miss out on our regular blog posts - Subscribe now!

Image of a laptop device to incentivize users to subscribe