Jen Jen - 7 months ago 18
Ruby Question

Ruby Watir deprecated methods

On installing Ruby & Watir recently to look at the company's web automation project I discovered that a bunch of methods being called have been deprecated. I'm struggling to find a good reference as to what to change the code to.

Is there a good reference (have searched a lot of watir site/manual/faq and not really found what to use instead - especially for the radio button checking if its set). Unless someone can confirm the below.

Changed:

browser = Watir::Browser.start(strURL)
browser.waitForIE


To:

browser = Watir::Browser.new
browser.goto strURL
browser.wait


Changed:

.select_list(:id, strHtmlId).getSelectedItems[0].to_s


To:

select_list(:id, strHtmlId).value


Changed:

radio(:id => strHtmlId).isSet?


To:

radio(:id => strHtmlId).set?

Answer

I just came across the watir-classic change log:

http://rubydoc.info/gems/watir-classic/3.2.0/file/CHANGES

It seems to do a pretty good job of highlighting at least the last two changes you mention (see the version 1.6.5 changes). Note that the watir gem that you were likely using before is now the watir-classic gem.

Regarding the first change you mention, that is actually due to the recent watir 4.0 release, which is now a front end for the watir-classic and watir-webdriver gem. You can change the code as you mentioned, or you can require 'watir-classic' instead of require 'watir'. I ran into the same issue with the Browser::attach method and briefly blogged about it on my blog.