Are Selenium tests worth maintaining?

Many teams struggle with maintaining proper selenium tests over the time. We look at what makes selenium tests easy to maintain and how to prevent bloated tests.

What is Selenium?

Selenium is a library that has been used for testing software on browsers. It automates through code, how a user clicks and uses the webpages. It helps teams to come up with test coverage that mimics the users.

What languages are supported by Selenium?

Selenium supports a multitude of languages. The most popular being Java, Ruby, and Python. Each language has a wrapper library around selenium that helps to drive automation in browsers.

Selenium tests

Though Selenium tests help to automate a lot of UI testing, these tests are complicated because of the following:

  • Tests mostly use xpath or css selectors to identify elements in the page
  • A small change in the Html markup or hierarchy could lead to broken tests
  • Selenium tests are not easier to understand
  • Selenium tests are sometimes flaky - which means that the same failing test if run again, could pass
  • It does not help to increase the confidence of the developers due to its complex nature

Worth it?

We at RocketApex consider the following before answering this question:

  • Do not use selenium directly; instead, write tests using a wrapper like Capybara (in Ruby on Rails)
  • Selenium should be a driver and not the direct test cases
  • Ensure that the tests have a better degree of readability (like using rspec)
  • Create your DSL

By using an abstracted layer of tests above Selenium, we have found that the complexity of Selenium tests decreases. It becomes maintainable and usable. Also, flakiness is addressed as and when it occurs, and thus tech debts are paid immediately. We have seen that having a UI test suite helps immensely over some time.

Related Articles

Subscribe to our newsletter

Perspectives from RocketApex

We send a monthly newsletter covering how you can improve your software development efficiency within your teams, build more meaningful products and deliver more value to your customers. Other than that, we don't spam you except to wish you on holidays!

* indicates required