What Is Selenium?
Many testing teams use Selenium. Here we cover what Selenium is, how it works, and if using Selenium is a good idea for your team.
What Is Selenium?
Selenium is a set of tools that allow you automate web testing.
Unlike some tools out there, Selenium is pretty easy to define:
“Selenium automates browsers. That's it!” — SeleniumHQ
It’s really that simple. Obviously, in practice, there’s a little more to it than that.
Introduction to Automated Testing With Selenium
Selenium was born in 2004 when Jason Huggins — an engineer at ThoughtWorks — was working on an application that required lots of manual testing.
Over the next few years, other developers got involved in the project and a few Selenium-related projects were spawned, including Selenium Grid, Selenium IDE, and Selenium WebDriver. This increasingly powerful set of tools is, as of now, essentially one fully coordinated test framework.
[Related Content: Testing With Selenium]
How Does Selenium Work?
Selenium is a test automation framework that allows you to automate web app testing. With languages like Java, Python, Ruby, C#, you can write test scripts to run against browsers and VMs. Some teams do this themselves, and some rely on a cloud-based solution.
How Is Selenium Used for Automated Testing?
Selenium is an automated testing framework. The framework executes test scripts against different web browsers, like Chrome, Firefox, and Safari.
What Cannot Be Automated Using Selenium?
Selenium cannot automate mobile app tests, as it is only for web app testing. Selenium cannot automate captcha. Selenium WebDriver cannot read bar codes. And Selenium cannot automate OTP submissions either.
What Types of Testing Can Be Done Using Selenium?
How Do You Write a Selenium Test?
When Should Selenium Be Used?
Selenium should be used to automate web tests that occur frequently and are repetitive. If it is time consuming to do manually and the requirements are low risk, then the test should be automated with Selenium.
Related Reading: How to Decide Which Types of Test Cases to Automate
3 Components of the Selenium Platform
Going a level deeper, there are 3 main components in the Selenium platform.
1. Selenium IDE
The Selenium IDE is a browser-plugin-based GUI tool. It facilitates recording, playback, and testing of user actions in the browser. It’s also a great way to get a feel for what Selenium can do.
Selenium IDE is suitable for creating quick and simple test scripts for bug hunting and basic functional testing.
Quite recently, the Selenium IDE project was redesigned. It now works on both Chrome and Firefox browsers.
2. WebDriver (aka Selenium 2.0)
Often referred to as “Selenium 2.0”, WebDriver expands and improves on Selenium Remote Control. WebDriver does what it says. It drives web browsers at a lower level than Selenium IDE.
WebDriver consists of a set of APIs that allow the tester to control the browser from an OS level. This can lead to much greater efficiencies in more complex automation setups. It supports headless browsers as well, which can also really speed up your testing.
WebDriver is more suitable for more advanced, complex, scalable automation.
As of today — and especially in the upcoming Selenium 4 version — WebDriver protocol is W3C compliant. It replaces the older JSON Wire Protocol.
The Selenium WebDriver technology allows you to create your test code in the following languages:
The Selenium framework supports 7 different object locators as the way to interact with web application properties. This is very critical to the success of test automation creation.
You can click, swipe, and enter text through the following locators:
- By CSS ID: find_element_by_id
- By CSSclass name: find_element_by_class_name
- By name attribute: find_element_by_name
- By DOM structure or xpath: find_element_by_xpath
- By link text: find_element_by_link_text
- By partial link text: find_element_by_partial_link_text
- By HTML tag name: find_element_by_tag_name
3. Selenium Grid
Selenium Grid is a tool which allows spreading tests over multiple physical or virtual machines. It allows for parallel testing and scaling.
Selenium Grid is a tool that allows the parallel execution of WebDriver scripts across as many real or virtual machines as are needed. It consists of a “hub” and multiple “nodes”. The hub is essentially a server, a centralized point from which to control and communicate with the nodes. The nodes are basically targets which execute the Selenium scripts.
Selenium Grid adds speed and efficiency. This can be critical to your automation success.
Perfecto offers a Selenium Grid in the cloud in various geographies. This removes the pain of creating, maintaining, and scaling web test automation.
You can seamlessly point your existing Selenium scripts to the Perfecto cloud. Simply provide 2 configurable parameters. And define the mobile and browsers capabilities on which to execute the tests in a testNG data provider XML file:
- Perfecto Cloud URL
- Perfecto securityToken
[Related Blog: How to Use Selenium Grid]
Is Selenium Testing Good? Pros and Cons
Selenium testing is good because it is a very easy tool to get started with. And it does what it promises.
Selenium is the core foundation to a large variety of test automation frameworks. This includes WebDriverIO, Protractor, and Cucumber.
And Perfecto’s codeless selenium solution relies on the Selenium capabilities for record and playback automation testing.
But Selenium has its drawbacks. When you ask testers about the biggest problems they see in the field, they will invariably say “test management”. This is an interesting problem because it’s not really a flaw with Selenium itself.
Easy to Use
It’s more a byproduct. Selenium can be a victim of its own success. Or to be more precise, you can be a victim of your own success with Selenium. It’s easy to get up and running with your first automated tests. And it’s easy to add new ones.
The De-Facto Standard
Many already have large test suites of Selenium test automation scenarios. These scripts run across desktop browsers and mobile web browsers. In addition, Selenium integrates seamlessly with CI/CD and other DevOps technologies.
Difficult to Manage
But before long, you end up with huge amounts of test data that can be difficult — or impossible — to process and analyze. As you scale up, you can quickly end up with an unmanageable amount of test results to comb through.
Unfortunately, Selenium itself doesn’t really help with that. So, when you set out to build your automated testing strategy around Selenium, you need to consider the big picture. And that means the extra tools you’ll need to deal with test management, reporting, etc.
Difficult to Maintain
In a DevOps world, code is constantly changing. There are strategies and techniques an organization can use to try to mitigate the effects of changing codebases on automated testing. (Think microservices, etc.)
But no matter how well you plan, code changes eventually break tests. This means that test script management is tough — and doubly important.
You also need to consider infrastructure maintenance. Setting up a device lab and a Selenium Grid aren’t tasks to be taken lightly. Much like code, browsers and devices are changing all the time. Keeping an up-to-date test lab takes a serious amount of energy.
Insufficient Test Reporting Abilities
Selenium is great in automating, creating, and executing tests. But Selenium lacks visibility into , test reporting and test data creation (like video recording, HAR file generation, cross-platform comparison, and CI dashboards).
This is where the power of the cloud comes in. Rather than trying to set up a proper in-house test lab, a better strategy might be to make use of a cloud service. One of these is Perfecto’s Cloud-Based Lab. Perfecto takes the headaches out of ensuring proper test coverage on a day-to-day, week-to-week basis.
[Related Blog: Limitations of Selenium]
Selenium Tutorial: Tips For Getting Started
If you’re just getting started with Selenium, consider the following tips.
It’s pretty much the #1 scripting language in the Selenium world and there are lots of tools and add-ons that can make your life easier.
2. Use a Cloud-Based Solution
Setting up Selenium Grid and scaling it takes serious technical chops. Start with a cloud-based solution rather than spending huge amounts of time and money setting up your own Grid. This will let you spend more time developing your tests and less time worrying about infrastructure.
3. Think Platform and Scenario Coverage
Web testing in today’s digital transformation involves mobile — not just web.
Each web application — whether it’s responsive, progressive, or just web — is being consumed across both desktop and mobile devices. It’s important to ensure sufficient test scenario coverage across the platform. This includes context, location, screen characteristics, and other considerations.
In addition, mobile and desktop web platforms changes constantly. So, following a market coverage index and recommendation is a great way to keep up with these changes — and ensure great user experience.
4. Test all Types of Aspects
Selenium is typically associated with functional test automation. However, a winning test strategy must consider all testing types:
- And more
Ensure that you have allocated time blocks within your development cycle and inside your CI for:
- Performance testing
- Visual validations
- Other relevant scenarios
This is important to maximize quality and mitigate your business risks.
5. Use Test Reporting
Managing tests and reports is the #1 headache for practitioners — especially in a fast-paced DevOps environment where code is changing all the time. Whether you need enterprise-grade results or just spend less time debugging flaky tests, consider the advantages Perfecto offers.
Use Selenium With Perfecto
Selenium is the #1 choice for automating testing across different browsers and platforms. And Selenium is here to stay.
You can get more out of Selenium by pairing it with Perfecto.
Perfecto and Selenium are seamlessly integrated. This allows customers to run their Selenium test automation scripts on real browsers in the Perfecto-secured and enterprise-grade testing cloud. You’ll get all of the benefits of testing with Selenium — without the drawbacks.
See for yourself how Perfecto can help you maximize Selenium. Get started with a free trial today.