views:

4088

answers:

6

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.

+1  A: 

I have tried Watir but not with cucumber. It was for java app. Problems we faced were with was trying to determine page is loaded. We had to scrape the forums a bit before finding the solutions. Otherwise it was fine.

+2  A: 

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.

Julian Birch
+2  A: 

You may want to try WebDriver. It will become part of Selenium in the future. Works with JRuby.

It is different than Selenium, Sahi or Watir in the way that it controls the browser natively, not using JavaScript, and is not affected by many issues other solutions have.

Adam Dziendziel
+9  A: 

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.

Patrick Lightbody
+3  A: 

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.

Dema
You may also like to use it with capybara which allows you to easily switch between celerity and selenium. Good article about it here http://www.allenwei.cn/cucumber-capybara-what-we-need-for-rails-integration-test/
Derek Ekins
+1  A: 

Watir 2.0 will also use WebDriver.

Bret Pettichord