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.
Selenium can be used to automate testing of any web application, built using any technology stacks. From Linux-based web applications built in Java, Python or Node.js to Windows-based .NET web apps, and literally anything else. It works with plain HTML but equally well with advanced client-side JavaScript frameworks such as Angular.js.
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.
Point and click to capture any button, image, or field on your screen. LEAPWORK’s smart algorithms automatically find the best way to locate it again in the future.
Nobody likes to wait. With implicit wait controls, LEAPWORK flows automatically wait for the right object to be found before executing next step in your test case.
Flowcharts are king. There’s no better way to maintain overview of your process – or the steps needed to perform a process. And that’s why your tests are best designed as visual flowcharts.
Skip the maintenance workload by building custom sub-flows for commonly used processes and steps. Edit sub-flows in a single place and use them across teams and projects.
Test applications in any operating system, any desktop or mobile device, and any browser version. LEAPWORK comes with built-in Sauce Labs and BrowserStack cloud integrations.
Automated tests can run on both local, remote, and virtual machines, in closed networks, and in the cloud. Timing and frequency of run schedules are completely customizable.
Plug LEAPWORK into your CI/CD pipeline using our public REST API. LEAPWORK comes with ready-to-use plugins for most common DevOps tools and orchestrators.
Make the right decisions with powerful live dashboards and reports. Reports are exportable and fully customizable by using filtering and grouping options.
Test cases are automatically documented with video recordings, text logs, and time stamps. All actions and events are recorded in audit trails. Replay and inspect for fast troubleshooting.
Team work is about working better together. With project asset sharing, easy hand-over, user roles, and access profiles, there’s no stopping you or your team.
Every single action in LEAPWORK is encrypted and tamper-proof – and automatically tracked in audit logs. Roll back to previous versions of automation flows with revision history.
With C# and JavaScript building blocks, LEAPWORK lets you insert code to your automation flows if you want to. Go further with our fully documented, public REST API.
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!