En
Python and Java programming code examples illustrating object-oriented principles in software development
Automation

6 steps to create and export Selenium IDE tests

The aim of this blog is to show you in 6 steps how to install the Selenium IDE Add-on, create basic Selenium IDE automation tests by recording, execute them and export them into a programming language (e.g. C#, Java, Python).

What is Selenium IDE?

Selenium IDE is a Firefox/Chrome Add-on that helps create Selenium test cases and test suites against web applications. It is a useful tool to create the bulk of your Selenium scripts, but it does also have its limitations.

For this blog, we will concentrate on just Firefox, although Chrome is pretty much the same.

1. Install the Selenium IDE Add-on

The first step is to download the Selenium IDE which – at the time of writing – is via the following URL:

Just click on the browser you are interested in (for these notes we are going to use Firefox, although Chrome is really not that different).

A webpage for Selenium IDE is shown, with links to download versions for Chrome and Firefox, and to view release notes. A white arrow points to the "Firefox" download link.

This should take you to the actual Add-on page.

Screenshot of the Firefox Add-Ons page for Selenium IDE, showing its logo, a brief description, and a blue "Add to Firefox" button for installing the extension. The Extensions tab is selected in the menu.

Clicking the Add to Firefox button will start installation.

A pop-up for the Selenium IDE Firefox add-on requests permissions, listing access to data, browser tabs, notifications, downloads, and activity, with "Add" and "Cancel" options. Firefox Browser Add-ons logo is shown in the background.

After accepting all the defaults, it will appear on your browser toolbar.

A computer application window showing minimise, maximise, and close buttons on a purple bar, with several grey icons below, including a bookcase, document, and user profile icon on a dark background.

2. Record a script to create tests using the Selenium IDE

To record a test case:

Ensure you have browsed to the Application under Test (AUT) that you wish to record against.

For these notes we have our own website.

From the Firefox Tool bar, select the Selenium IDE icon.

A Firefox browser window showing the LAMP Music Store website loaded at "localhost/MusicStore/," with the Selenium IDE extension icon highlighted and a tooltip displaying "Selenium IDE.

The Selenium IDE Application will start by displaying a menu:

A pop-up window in Selenium IDE version 3.16.1 displays options: "Record a new test in a new project," "Open an existing project," "Create a new project," and "Close Selenium IDE," with related project links.

As we have never used it before, the above screen is selecting the first option.

When creating a new project, it will ask for the name. For these notes we have used the imaginative name of demo.

A pop-up window titled "Name your new project" prompts the user to enter a project name. "demo" is typed in the text field. Below are "Cancel" and "OK" buttons, with a cursor pointing at "OK".
It will then want to run a test, and will prompt you for the project’s base URL. You can get this by copying the main URL from the original browser window and pasting it across.
A browser shows "localhost/MusicStore" with a music store webpage on the left; on the right, a pop-up prompts to set the project's base URL, with "http://localhost/MusicStore/" entered in the field.

Selenium will then open a new browser window which you use to record your steps for your test.

A partial website interface showing music genres and a search bar. Below, a highlighted message in a red-bordered box reads "Selenium IDE is recording" with a red dot indicator.

From this point forward the IDE monitors all mouse interactions and keyboard inputs and records them in the Selenium IDE interface. Until you stop the recorder.

Selenium IDE does have a habit of placing the web page in a window in front of the Selenium IDE and will record the action of moving it in your script.

A screenshot shows Selenium IDE recording a test in Firefox, with two windows: one for Selenium IDE and another for a web page displaying disco album covers at "Lamp Music Store" under the Disco Albums section.

The Selenium IDE table tab will then display all actions captured by the recorder. It is possible to view, modify or delete commands from this view. To delete a command, right click on the command and select delete from the menu.

When all recorded steps are complete, stop the recorder by clicking on the red circle.

A screenshot of Selenium IDE in Firefox, showing a "Stop recording" tooltip hovering over a red button on the top right. The project is named "demo.

To save your test, you will need to save the entire project, click on the Save project button in the top right-hand corner of the IDE screen.

Screenshot of Selenium IDE in Mozilla Firefox, showing a project named "demo" with the "Save project" button highlighted and a cursor pointing to the save icon.

3. Replay the script in the Selenium IDE

Once all the required test steps have been captured, you can now replay the test by clicking on the Run current test icon.

A cursor hovers over a blue "Play" button in a software interface, showing a tooltip that reads "Run current test Ctrl+R." Various other icons and a search bar are visible on the toolbar.

If you have closed the window Selenium used to record the test, the IDE will now open it again.

On successful execution of the test the captured tests steps will turn green:

Screenshot of Selenium IDE in a Firefox window showing a test project named "demo". The steps include opening "/MusicStore/", setting window size, clicking "Disco" link, and verifying results. The log reports all steps as successful.

Should the test fail, the failed line (usually highlighted in red) and the failure count on the left-hand side will increment by one.

A screenshot of the Selenium IDE showing a test script with commands like "open", "set window size", and "click". The status bar at the bottom indicates 1 run and 1 failure, with an error message in red.

Any errors also appear in the log tab at the bottom of the Selenium IDE interface.

Inserting Commands

When using Selenium IDE as an automated test tool it is inevitable that you are going to need to modify the recorded steps to include an additional step e.g. an extra click, some synchronisation or an Assertion (A method of passing or failing a test).

To insert a new command:

Select the point in the script where you wish to place the new command. Right click the Selenium IDE interface and select Insert New Command
A computer screen shows a software testing interface with a right-click menu open. The "Insert new command" option is highlighted. The test run shows 1 failure at the bottom left-hand corner.

Initially the new command will appear in the script as a blank line.

Structure of a line in the test case

Each command requires up to three inputs:

  • Command
  • Target
  • Value
A table showing four rows of automated test commands with columns for Command, Target, and Value. Commands include open, set window size, and click, with targets such as /MusicStore/ and linkText=Disco.

To insert a new command:

Command is the action the Selenium Script is to perform. Commands range in functionality from Navigation e.g. Click a Button, Synchronisation e.g. Wait for text to appear on the screen and Assertions e.g. ensure the correct text has appeared on the screen.

To select a command, click on the black arrow to expand the drop-down list of available commands.

Target

Target refers to the Object or “WebElement” that you wish to record the action. For example, if the Selenium IDE script was required to click on a link a “description” of the object would be included in the target field.

Value

The value is an optional field used when the command needs some additional information. For example, if you want to type in a text box, then this field would contain the text you wished to type.

4. Replay all tests in the Selenium IDE

If the Selenium IDE project has more than one test, we can run them all sequentially.

In the screenshot below, we have a couple of tests sitting in the IDE…

Screenshot of Selenium IDE in Firefox showing a test project named "demo." The selected test, "searchMetallica," includes steps to open a URL, click a search box, type "metallica," and click a music link.
A Selenium test suite wA Selenium IDE test suite with more than one test case.

To execute all tests in the test suite, select the Run all tests button:

A cursor hovers over a button labelled "Run all tests" with shortcut "Ctrl+Shift+R" in a web interface, next to a section labelled "Tests" and a search bar.

The test cases show up as green when the tests have executed successfully:

Screenshot of Selenium IDE in Firefox showing a test script named "searchBlackSabbath" with steps to open "/MusicStore/", enter "black sabbath" in a search box, and click on related results.

5. Export the tests from Selenium IDE

The Selenium IDE enables recorded test cases to be exported to a range of programming languages and their respective testing frameworks.

To do this:

Either right-click on the test name or hover the mouse near the end of the test name field until three dots appear.

A cursor hovers over a vertical menu of three blue dots next to a highlighted test named "demo1*" in a software interface, under a "Tests" section with a search bar.

Click on this and select export.

A drop-down menu is open with options: Rename, Duplicate, Delete, and Export. The Export option is highlighted, and a hand cursor is pointing to it. The menu appears below an item labelled "demo1*".

Selenium will then prompt you to select the language (in this example we have selected C# NUnit).

A dialogue box titled "Select language" shows language options with "C# NUnit" selected. There are tick boxes and two buttons labelled "Cancel" and "Export"; a cursor points to "Export".

Give a filename and save it in the desired location.

Screenshot of a Windows "Save As" dialogue box. The folder "Answers" is shown, the file name entered is "Demo1Test" and the Save as type is set to "CS File". The "Save" button is highlighted.

The choice of programming language and test framework would be either be a personal preference or an organisational norm and would depend on tools and skills of the tester or developers available.

6. Running Selenium IDE test cases from the command line

Once you add the test cases into a Selenium IDE test suite, it is possible to execute them from the command line.

Open a new instance of File Manager (“Win + E”).

Navigate to the folder where you saved your project (the file with the extension “side”).

A Windows File Explorer window shows the contents of the "Sekawan All" folder, including a subfolder named "Documents" and two files: "Listy.pdf" and "Logo Sekawan.jpg". The window displays file names and sizes.

Hold down Control & Shift and then Right click the mouse and select Open PowerShell window Here:

A Windows File Explorer window shows a folder with files. A right-click context menu is open, highlighting the option "Open PowerShell window here." The background shows common folders and file navigation.

Run the tests from the command line

In the terminal window, type in the following:

selenium-side-runner *.side

This will run selenium from the command line.
A terminal window displays Selenium test results: one test suite with three tests listed. One test passed, none failed. Time taken is 4.013s. The test file run is "defaultSuite.test.js" in the "Exercise 3 - Selenium IDE" directory.

To exit out of the terminal window, type in exit.

Want to find out more?

Want find out more about setting up the Selenium IDE, exporting test cases to other languages and running them as actual code?

Well, at the Expleo Academy we deliver courses on Selenium and many other subjects. Feel free to visit the Academy website.

  • If you are interested in learning all about how to use Selenium with Java then feel free to have a look at out Using Selenium with Workshop course.
  • If you are interested in learning all about how to use Selenium with Cucumber then feel free to have a look at out Using Selenium with Cucumber course.


More information on the Selenium IDE can be found at the following location:

https://selenium.dev/selenium-ide/docs/en/introduction/getting-started

John Kurowski has been delivering training for over 10 years specialising in Automation, Agile and ISTQB. John also develops the courseware and creates virtual machines in AWS for automation courses.
John has been working in IT for over 30 years and has also been a tester, test manager, developer, development manager, project manager, support consultant (the list goes on…)