Skip to Content

Simplelenium, writing robust tests with Selenium

I use Selenium a lot. And I hate it! I hate it and I use it. Every other browser automation tool I’ve used either has the same problems as Selenium or end up dying because nobody uses it. There are nice librairies to make writing Selenium tests more user friendly. Fluentlenium is one of those nice tools. But Selenium’s problem is not really with its syntax. It’s the complexity of writing stable tests. It’s hell!

If you test modern websites with Selenium, you end up playing with waits and timers. Very often people put random Thread.sleep(s) into their test code because they are just fed up trying to understand why sometimes the test passes and sometimes not. The questions you need to ask yourself when you write a Selenium test are:

  • Should I wait before it test the content of this element?
  • How long should I try before I retry?
  • What should I do with freaking Stale Element Reference Exceptions?

I’m so upset every time I write Selenium tests or work on Selenium tests written by customers that I finally took some time to write my own layer on top of Selenium and PhantomJS. The prototype is called Simplelenium. With Simplelenium, you should be able to write robusts tests without all theses questions.

There’s a lot missing in this library but I’ve used it in production and my tests are much more stable. Tell me what you think about it.

comments powered by Disqus