This article is an introduction to Selenium and the benefits of using it in automated web application testing. In the article we will start by outlining the skills, effort, and resources required to succeed with Selenium, how to use Selenium and what you can use it for. Finally, we will conclude the article by proposing a tool you can use to work in Selenium without having to code.
Selenium is a free, open source and very powerful programming framework that can be used to drive web browser behavior such as clicking on buttons, typing into fields and so on.
Using Selenium, you can do anything a regular user can do in a web browser like Chrome, Firefox or Internet Explorer.
Programmers are able to write code for Selenium in languages such as Python, Java or C# that loads web pages, performs required actions and checks for expected results.
The following is a very simple example of doing just that, borrowed from Sauce Labs:
In the above example, Selenium is used to load the “www.SauceLabs.com” web page and look for a button that links to the “/beta/login” URL, and to check that the text inside the button is “Sign In”.
Customers expect high quality software, but the ever-increasing demand for faster time to market puts QA organizations under a lot of pressure.
Testing is key to ensuring reliable and consistent software behavior and automating major parts of the testing effort is almost always required to meet deadlines.
For automation of web application testing, Selenium has many benefits:
No other tool or framework comes close to this impressive list of benefits.
However, it’s important to understand that Selenium’s greatest power is that it gives programmers “raw” access to the browser. Therefore, the programmer must have professional experience in order to write and structure the code in a way that can easily be maintained.
Another thing to note is that Selenium itself only drives the browser; it does not record results or have any reporting capabilities – that’s for the programmer to create and maintain, typically by integrating the Selenium code with an Application Lifecycle Management system such as Azure DevOps.
In inexperienced hands, Selenium code can lead to an unmaintainable and unscalable mess. But before we get into a solution to that, we need to look at typical use cases for Selenium.
Because of this, Selenium is an excellent choice for automating testing of web-based enterprise applications such as ServiceNow, Salesforce, SharePoint, Sitecore, SAP and many others -- including those not beginning with the letter ‘S’.
All of these examples have a lot of things in common. As explained in the Sauce Labs’ introduction to Selenium, there are six basic steps in creating a Selenium script for test automation:
It sounds straightforward, but it’s clear from the example in section 2 above that it’s a very complicated and time-consuming task to write the appropriate code.
However, as you can see in this comparison of LEAPWORK vs. Selenium Web Automation, the biggest problem facing non-professional programmers isn’t actually getting the automation code to work initially -- it’s maintenance of the scripts, particularly in an enterprise environment.
Besides creating the test automation scripts themselves, making Selenium work as a test automation tool also requires:
It’s important to note that Selenium does not work with any type of desktop application. Only the content displayed in web browsers can be automated. Even automating the features of the browsers themselves, such as turning extensions on or off, are out of bounds for Selenium.
Typically, for enterprise test automation, testing needs to flow across different application types. For instance, a back-office application built for Windows desktops in WPF (Microsoft .NET) might be needed to setup an account, after which a web front-end needs to be validated, alongside records produced in a mainframe or maybe on a Citrix screen.
For these scenarios, Selenium can only cover the web browsers, and other automation solutions must be found for the remaining application types.
In the next chapter, we’ll show how to use a single tool to achieve fluent automation across all application types, without having to use code.
On a general level, using Selenium means performing the following types of actions:
Imagine if these Selenium actions were represented by building blocks that could simply be wired up together visually.
This is what we do at LEAPWORK. We’ve built a next-generation visual language that everyone understands, and which uses Selenium to perform all actions.
Here’s an example of codeless web automation. It’s a simple flow that creates contacts in Salesforce from an Excel spreadsheet, and then validates that each contact is correctly stored:
Flows like these typically take only a few minutes to create, compared to hours of coding that would otherwise be needed.
The following is a quick side-by-side comparison of using coding in Selenium vs. using LEAPWORK codeless web automation:
This completely codeless approach enables any business users to automate testing of web applications, without having to know anything about code.
Software testing can be difficult and costly. Test automation reduces errors, cuts back on resources required, and improves the ability to scale tasks.
The Selenium framework has nearly a third of the market for automated web testing because it can reduce risk and increase test execution. Nevertheless, challenges remain with test automation based solely on Selenium: Testing across application types (desktop, Citrix, etc.) and not least having to write code.
With LEAPWORK, all business users can automate processes for increased accuracy and reliability. Successful test automation is within reach!