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
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.
- 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.
- 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.
- Navigate to Keywords
- Click the Upload Package button
- 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.
- 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
- Navigate to Plans
- Click + to create a new plan
- Enter a name
- Select “TestCase” as a Template
- 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”.
- Click on “Keywords” to open a list of available keywords
- Find the Keyword “Opencart RPA Testcase - Admin Login” and click its + button to add it to the plan
- Click on the newly imported keyword
- Configure the login step: fill “true” in the “headless” field
- Fill in “demo” as username
- 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”
- Select the root element of your plan
- Select “Controls”
- Find the “ForEach” control and click the + button to add it to the plan
- As “Source Type” choose “CSV”
- Drag and drop or use the file chooser to choose the prepared CSV file:
5. Loop the Update-Product-Keyword
- Select “Keywords”
- Find the “Update Product” Keyword and click its plus button to add it to the loop.
- 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.
- Mark that field as “dynamic” by activating the button with the lightning icon.
- In the “quantity” field, type “row.Quantity”.
- 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
This article demonstrates how to connect Grafana to data generated by Step.
This article demonstrates how to set up distributed system monitoring using Keyword executions, and analyze the results as measurements.
This tutorial demonstrates how to automate interaction with Microsoft Office applications using the Office Interop Assembly.
This article provides documentation for how to integrate JUnit tests into Step.
This tutorial demonstrates how Step can be used to monitor services, availability and performance metrics.
This tutorial demonstrates how to utilize the AutoIt C# binding to automate interactions with Windows applications.
This article demonstrates the automation of mobile applications on Android using the Appium framework.
This article defines three Keywords which will be used in browser-based automation scenarios, using Step and Selenium, as general drivers.
This tutorial shows you how to efficiently set up a browser-based load test using existing Cypress tests in the Step automation platform.
In this short tutorial, we show how to quickly implement a simple browser-based load test based on Cypress scripts in Step.
This tutorial shows you how to efficiently set up a browser-based load test using existing Playwright tests in the Step automation platform.
This article explains Keywords in Step and demonstrates how to create simple ones.
This tutorial demonstrates the design, execution, and analysis of functional tests using the web interface of Step.
This tutorial demonstrates how to use Step and Cypress to automate various browser tasks.
This tutorial demonstrates how Selenium automation tests can be turned into full synthetic monitoring using Step.
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.
This tutorial shows you how to efficiently set up a browser-based load test using existing Selenium tests in the Step automation platform.
This tutorial demonstrates how Playwright automation tests can be turned into full synthetic monitoring using Step.
This tutorial demonstrates how Cypress automation tests can be turned into full synthetic monitoring using Step.
This tutorial will demonstrate how to use Step and Playwright to automate various browser tasks.
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.
Want to hear our latest updates about automation?
Don't miss out on our regular blog posts - Subscribe now!