I’ve been looking into automation tools. I was messing around with Selenium a bit and made some scripts to help us do some stuff more quickly. Before investing too much in a particular tool though, I wanted to look around a bit at what else might be out there. I came across TestCafe and heard some good things about it and so thought I’d give it a try. I’m new to both tools and so I thought as a newbie why not compare the two? So here goes:
We need start with the important thing first: colors. More specifically are there pretty things and do the colors make me happy? Selenium/webdriver? Not really. TestCafe? Well, it has enough good looks to make a beauty queen jealous.
Joking aside, one of the things I like about TestCafe is that it gives me some info about what it is doing during the run with a status bar at the bottom. This kind of gives a peek into the mind of the system and makes debugging easier. TestCafe also give nice debug output in the console for failed tests
Installation and setup.
What about setup? How hard is it to get started? For TestCafe, all I had to do was
npm install -g testcafe
and about 30 seconds later it was done. My first test was running about 15 minutes later. Selenium wasn’t too bad either, but I did have to install webdriver for a few browsers as well as pull in some selenium packages into python. Since I was driving things through python for my test the selenium part was pretty easy:
python -m pip install selenium
but there was still some added complexity with getting webdriver to work for all browsers and setting up the first test was a little more complex as well. All in all, it probably took about an hour to get my first test running with Selenium/webdriver.
The whole purpose of this is to be able to more easily check thing across different browsers right? So how easy is that to do? With both tools I first ran the test in Chrome, because well, that is the browser all sane people use right? Once I had my test working in Chrome I tried running in other browsers. In both cases the test didn’t work in any other browsers. It took me a while with the Selenium test to work through the issues (mostly involving issues with timing and waits).
Much like renewing your drivers license, the most annoying part of using Selenium is dealing with waiting. The trick is to get it to make sure that what I want is there without letting it have a nap every few seconds. I probably spent more time on trying to figure out waits than anything else (and to be honest in the script I made there were still some explicit sleeps() in place). With TestCafe, this just worked. They have implicit waits build into the async calls, and it worked out of the box. This is actually the primary reason I was able to get the first test working so quickly. I didn’t have worry about waits.
Selenium has a lot of support in various languages. For me that meant I could use python and feel that joyful feeling that comes from coding in python. It also means that you can write your tests in the same language as your app or your favorite language (which of course, is python).
Webdriver and selenium have been around for a long time. They have grey hair. They might even have considered dying it. TestCafe, however, is fresh out of college and ready to take on the world. Full of wide eyed wonder and optimism, it’s exciting to use and has all the energy of youthful optimism.
With age and maturity comes experience and webdriver has that in droves. When you google around for answers to questions and problems you have, you find answers. Lots of answers. Answers of people who have been through what you’re going through and who have the scars to prove it.
TestCafe has seen the problems of webdriver and with all the enthusiasm of youth has decided to fix them out of the box. This is really nice (see the waits section above), but when you do run into problems it’s a lot harder to find answers. There just aren’t as many example of people hitting the problems you have and so you rely much more on the documentation (which is really good by the way). Unfortunately documentation and well designed code still can’t anticipate every problem you will run into in the wild and having a large community around a tool is really helpful for figuring things out.
I was really impressed with TestCafe and I really want it to be the winner, but unfortunately if I can’t figure out the cross browser issues I’m having, I won’t be able to. Maybe (hopefully) those are just some weird issues we have in our app and for most people this won’t be a problem. I think that if you don’t see the weird issues I’m seeing on non-Chrome browsers, the overall winner would be TestCafe.
Winner: Selenium (For me, for now), TestCafe (If it works cross-browser on your app)