First released in 2004, Selenium was born from the need to decrease the manual time spent on testing repetitive functionality in a web application, e.g. testing the login page is unaffected by new changes. Since then, Selenium testing has matured to a world-class automated software testing tool.
With the increasing demand for automation, Selenium web testing is able to bring extensive benefits by automatically running selected test cases. And, as an open-source tool, anyone can access the software and participate in Selenium’s global community.
So, you want to learn Selenium software testing? This is a good place to start. The following guideline provides a good understanding of Selenium for beginners, it covers the core components and shows how to start your Selenium journey.
Selenium was developed in Java to create a test automation framework for web applications and requires some knowledge of programming and manual testing.
It is not overly complex to use Selenium, but knowing how to do certain things will be essential, such as being able to locate HTML elements in a browser by ID, Class, Name, CSS Selector, etc.
Selenium and Automated Testing
Simply put, Selenium automation testing lets you simulate repetitive tests performed on a web application. Whether it’s entering text and clicking buttons, or selecting the same option from a drop-down menu, Selenium records the mouse movements for playback during test execution.
Even though images and fonts may render the same, the browsers’ underlying processes have subtle complexities, which may surface later as errors.
Types of Testing with Selenium
Selenium testing can be implemented as an alternative or combined approach in multiple testing strategies:
1. Selenium unit testing can retest individual parts in an application like a page with one or two inputs, or a function or procedure.
2. Regression Testing repetitively tests existing (full or partial) functionality after changes, fixes, and enhancements.
1. Selenium performance testing determines environmental and application performance.
2. Stress Testing establishes breaking points and maximum load for a web application.
Understanding Selenium Basics
The core components of Selenium 1 are the Selenium Remote Control (RC) and Selenium Grid, which gives the ability to code and execute complex tests across multiple browsers and systems.
In 2011, Selenium 2 was released where the Selenium RC elements were merged, and the new WebDriver API was introduced. Essentially, the Selenium suite comprises 4 components:
The IDE is a browser add-on for creating simple test cases against Firefox or Chrome and is ideal for new users with little or no programming experience. The plugin records user actions which are executed later as test cases.
Released as part of Selenium 2, the WebDriver API allows test scripts to communicate directly with the browser and interact with the page elements. It’s not restricted to certain browsers and integrates with Chrome, Opera, Android, and iOS.
Advanced and customized test cases can be created with supported programming languages such as Java, C#, PHP, Python, Perl, and Ruby.
Selenium Remote Control and Grid
Selenium RC and Selenium Grid are now officially unsupported, but their capabilities were merged with the WebDriver. The WebDriver API is less complicated and faster than the RC while providing better page interaction.
Installing Selenium IDE
Starting with the Selenium IDE is a practical way to develop your Selenium knowledge before installing the WebDriver. The IDE will help you get familiar with Selenium commands and learn how to record and execute simple tests while building up your scripting knowledge.
Creating Test Cases
Open the IDE installed in your browser and select how to create your test:
1. Record a test case based on user and web interactions. Commands are automatically inserted based on the actions like clicking on a button or selecting a radio button option.
2. Use the page right-click option to Assert and Verify, where if the Assert condition is true, it continues to the next step in the test but if it fails, the testing stops. The Verify function reports on what failed but does not stop the testing process.
Executing Test Cases
After creating your first simple test, you can now execute it against the web application (in Chrome or Firefox). You can manage your test with user-friendly features like clicking Run to execute a test or Run All to execute tests in a test suite.
Setting breakpoints is another useful function that stops testing when a particular step or command is reached during test execution.
Selenium is versatile and integrates with various tools and applications to manage automated testing across different browsers and operating systems.
A number of tutorials, videos, and manuals online are freely available to download and the Selenium Wiki on GitHub is highly recommended for useful resources.
Investing in time and being committed to getting over the Selenium learning curve will set you up with a solid foundation in Selenium testing.
Kate Zalozna. CTO at QA Madness. I’ll share my knowledge and experience of implementing QA strategies and ensuring their alignment with a company’s business needs. After working in QA and software testing for over 9 years, I have a lot of things to share.