Why Selenium Should Be Your UI Test Tool

Selecting a testing tool is hard work. If you look on vendor websites, you'll get marketing material promising the world. If you look on forums, you'll mostly get people trying to solve their own problems. Justin Rohrman tells you why you might choose Selenium as your UI testing tool, based on real experience with real software projects—rather than a marketing page.

Selecting a testing tool is hard work. If you look on vendor websites, you'll get marketing material promising the world and then a call from their sales staff. If you look on forums, you'll mostly get people trying to solve problems relating to their product: "Why won't SuperUITester++ click Save on my Flash application when there are 4 other modals open?"

Let’s take a look at why you might choose Selenium as your UI testing tool with information based on real experience with real software projects—rather than a marketing page.

Why the UI

There are lots of different places you can begin testing software. I like to think of them as different layers in a product, just like sedimentary layers archaeologists dig through when unearthing ancient cities. You want to use the most appropriate tool for each layer of software you are looking at: smaller units, seeing how methods work together, fully formed APIs, simple scenarios in the UI, and complex product usage. All the layers are important; the question is how much of each you want.

The API and everything below that will give you a feel for code quality and some basic functionality. Testing the UI will help you know things from a different perspective: the user’s.

Why Selenium

The WebDriver object triggers real events in the browser: mouse clicks, button clicks, entering text, and events from the keyboard. Think of each step as a building block. Stacked together, they can enable a technical team to do some powerful things. Here are a few of the more common reasons for using WebDriver.

Building Automated Checks

Probably the most common reason people elect to use the Selenium suite of tools is to drive a specific set of commands and check status—to see if the user is logged in, if the book goes into the shopping cart, or if a transaction processes.

This includes checks to make sure buttons or labels are present on a page, data that you created saved correctly, procedural aspects of the software under test work accurately, or any number of other attributes of your product.

Put simply, you'll use WebDriver to ask questions you would normally be able to answer with a yes or a no, and WebDriver will kick out a report with the number of assertions, the ones passing and failing, and where the errors occur.

Once you have finished building your checks, you can run them once or many times and use them as a tool to discover problems, or even unexpected changes, between builds.

The questions you ask in the scripts are binary, but usually the process of writing and running them a few times will uncover important bugs that the scripts aren't even looking for.

User Comments

Thomas Melville's picture

Hi Justin,

I enjoyed reading your article.

Selenium is in my opinion a great open source tool for Web UI testing. It does currently have a major drawback: newer browser versions not working with older versions of Selenium and vice versa, this causes nightmares for us when for example firefox automatically updates on testers machines and suddenly the tests stop working. I'm delighted to hear that the W3C is working on a spec for the WebDriver! Do you know if the the browser makers have into bought writing and taking control of the web driver implementation for their respective browser?

June 23, 2015 - 2:55pm
Rasmus Koorits's picture

Hey there!

If you need to create hundreds of slightly different users or gigabytes of data in a realistic way, Selenium can help.

For realism of test data, a browser driven way for creating users seems like a good idea. However, I would argue that most of the time a http request based approach can be just as realistic, less flaky and much, much faster.

I would thus offer something like the Python requests library or even JMeter as a valid alternative to selenium for this task.

June 29, 2015 - 6:37pm
George Cai's picture

You can say it again!

UI automation scope should be minimized since it is very expensive (to create, to run and  to maintain) and less productive comparing with other approaches (such as http api call)

January 4, 2016 - 5:26pm
Jena Buttimer's picture

I totally agree. The way web applications are developed now, they are very service (api) heavy. Makes sense since web services aren't impacted by the browser. The way I've seen test automation change in the last 20 years, it has shifted from automating functionality to automating service testing. It just makes sense.

Services, once fleshed out, very rarely change other than adding methods so maintenance is at a minimum. Once they are all scripted in a tool like SoapUI Pro, they can be put together to test any flow you want and run as part of the build process or scheduled to run any time of the day or night. I can run a large suite with many, many assertions in about 2 hours whereas the same tests run through the UI take 12 hours or more. The debugging and updating can be an all day job.

I'm not saying that UI tests no longer need to be automated, but I think the value of UI automation has changed and should be assesed to determine exactly what needs to be automated and what can be executed manually. 

I think a tremendoius amount of time and money can be saved by taking a fresh look at the automation plan.

I die a little inside every time I hear a test manager say "I expect 100% automation!" LOL

January 5, 2016 - 5:17pm
Fiona Gibson's picture

Well, we all know about slenium testing is the best open source functional web testing tool. Here, Justin Rohrman you are written very clarifiying details which is is based on our real practise work.

July 10, 2015 - 5:46am
aravind gabani's picture

Main reason of using selenium as automation tool is 

  • It is open source.
  • supporting multiple languages.
  • support multiple plateforms.
  • Able to find online selenium tutorial and solution of any problem.
  • Many versions/projects.
  • Mobile app testing support using appium.
July 29, 2016 - 9:39pm

About the author

StickyMinds is a TechWell community.

Through conferences, training, consulting, and online resources, TechWell helps you develop and deliver great software every day.