How To Test A Web App With Selenium

Manual testing of software is time consuming, prone to missed cases and errors, and all around a bad idea, unless you’re just starting out learning to code and need to practice writing full test suites. Selenium is a suite of tools to help automate testing software - and is used to test web apps. Automated testing is a critical component of continuous integration and continuous development. Web apps work like an app on your phone or computer but work purely through the browser. Think apps like Canva and Trello.

What is Selenium?

As mentioned, Selenium is a suite of tools that allow you to do automated (mainly functional) testing. This includes the Selenium Web Driver, bindings to drive the browser for testing, the Selenium IDE, where you can quickly create scripts plus record and playback interactions from the browser, and the Selenium Grid, where you can test across multiple machines and configurations at once, A step up from manual testing is writing scripts that will run your manual tests for you. A step up from that is Selenium.

Selenium is open source and supports a wide range of languages including Python, Java, C#, PHP, Ruby, Perl, and JavaScript, plus works across operating systems and browsers. It supports parallel testing as well as TestNG, JUnit and NUnit frameworks.

Using Selenium

The Selenium IDE

The first thing that you will want to do is download the Selenium IDE, a Firefox and Chrome plugin used to create, execute, and debug your test cases. These test cases may be exported to your preferred programming language mentioned above. With the record and playback function, you’re able to examine just what’s happening within your web browser when running (user interaction) tests.

Interacting with websites

To use the IDE to see what’s happening with your website, simply open the website as your initial target site and start performing actions. You’ll then be able to see the commands, targets, and values within your Selenium IDE plugin.

Once finished you can close the window or stop recording. If you like, you can then run your ‘test’ again.

From there, you can right click on the test to export it to C# NUnit, C# xUnit, Java JUnit, JavaScript Mocha, Python pytest, or Ruby RSpec and examine the code yourself.

While the IDE is useful, it’s limited in application. To test properly with Selenium, you’ll instead need to use the WebDriver.

The Selenium WebDriver

As per the Selenium documentation, “WebDriver is an (object-oriented) API and protocol that defines a language-neutral interface for controlling the behaviour of web browsers.”

To use the WebDriver you will need to use and be familiar with one of the test frameworks we mentioned earlier. Let’s put it this way: the frameworks do the heavy lifting, the WebDriver API just tells the browser what to do. You will need to use the correct WebDriver for the particular browser you are working with. For the most complete testing, work across all browsers!

From there, you can write your own scripts in your testing framework of choice and use the WebDriver bindings to manipulate browser actions as a user would in their web app session.

Of course, to get good at testing with Selenium you’ll need to do lots of practice, as you would any other package. However for experienced coders (and those used to one of more of these test frameworks), it should be easy enough to get up and running with Selenium in not too much time.

If you are looking for more resources on working with Selenium, you can check out the official documentation, or search for courses or videos online to get you started. It’s a popular testing suite with a large community so you will find plenty of information to help out.

Need help with testing?

Plenty of organisations find that when they are handed a software product that it is still full of bugs. This is generally due to inadequate testing strategies.

Web apps need to be tested thoroughly before release and this includes using clever tech products like Selenium. Thought coders just needed to code? Without experience in comprehensive testing strategies you might wind up with a hot mess of a project.

If you are looking for help with testing your software, and need to get in touch with a developer that knows exactly how to work with Selenium, then look to CodeFirst. We have a range of developers experienced in all types of software tools - including testing with Selenium and developing the right tests.