Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium or Watir for Javascript Testing in Rails

We're using RSpec and Cucumber in our Rails apps with good results. Webrat is great for non-AJAX interactions, but we're getting ready to get back into writing tests for our Javascript.

Webrat has Selenium support built in, and we've used Selenium before, but I'm curious if anyone has had good results using Watir with Cucumber and what the pros and cons are of Watir versus Selenium.

like image 975
Abie Avatar asked Jan 20 '09 20:01

Abie


3 Answers

As the founder of OpenQA and Selenium RC, I'm obviously biased towards Selenium as a good option. We recently just put out a 1.0 beta 2 release and are very close to a 1.0 final.

However, you couldn't go wrong with Watir/FireWatir either. Adam's comment that WebDriver will merge to form Selenium 2.0 is correct, but he's incorrect in implying that Watir doesn't use native hooks. If Watir were simply a Selenium clone and also used JavaScript injection, I'd say it wasn't worth looking at.

But because it has native hooks, it can do some things that Selenium currently can't. While it has fewer browsers supported, it goes a bit deeper in the main browser it does support (IE) and lets you control things outside of the page/canvas.

In summary: either is fine, Selenium is great, and if you hang on a little longer with Selenium you'll soon get the best of both worlds with WebDriver/Selenium 2.0.

like image 133
Patrick Lightbody Avatar answered Sep 19 '22 14:09

Patrick Lightbody


I am having good results using Cucumber with Celerity through JRuby.

Celerity is a headless browser which wraps around HtmlUnit with a Watir-compatible API and supports JavaScript and AJAX testing.

Being headless makes Celerity faster and easy to integrate within a Continuous Integration build cycle.

Since Celerity is API-compatible with Watir, you can switch between Watir and Celerity fairly easily. There are some caveats, but it's been worth the effort.

like image 37
Dema Avatar answered Sep 17 '22 14:09

Dema


I'd say Watir was much slicker, but less useful. It's mostly an IE automation system, with fairly flaky Firefox support. (I'll admit to not having checked out FireWatir in a while, it may have improved.)

There is experimental support for Selenium-RC on Watir. That would definitely be the best of both worlds.

like image 25
Julian Birch Avatar answered Sep 19 '22 14:09

Julian Birch