I've been doing a bunch of this sort of work at my current job so I have the following advice. (something else I should do a blog posting about)
Step zero, decide if you are going to make the scripts try to run under both the newer Watir and Watir-Webdriver, or just WW. If the former I suggest a global $webdriver variable be used to wrap some code to be disabled, or create if/else wrappings around the few things that are entirely different I'm using a YAML config file to set which driver and browser to use, etc Step 1 if running on Windows install PIK it allows you to have multiple versions of Ruby installed and each can have it's own set of gems etc. For Mac get RVM it's similar only better. This allows you to use a single machine and flip it instantly between setups Step 2 source control is your friend (you know that already I'll bet) so will be search and replace Step 3 For updating the scripts I do the following (I've made notes as I went along, this is what I found so far) part 1 the basic updates that (should) work with both Watir 2.0 and WW: a) search for any instance of :index if the value is 1, remove it entirely (that's the default if nothing is specified), if the value is >1 reduce it by one. b) Replace: $ie or $ff with $browser or just $b (depending on your preference/style) c) Replace: browser.text_contains with browser.text.include? d) Replace: text_field.verify_contains("dfadf") with text_field.text.include?("dfadf') e) Replace: select_list.includes? with select_list.include? (singular) f) Replace: :url with :href ( !! in most element 'how' but NOT for window switching see below) j) .isSet with .set? Part 2 stuff from Watir you no longer need. Some stuff you had before is not necessary in webdriver remove/comment out or disable via wrapping with "unless $webdriver" if trying to be compatible with both Watir and WW) a) .document (anything) b) .document.scrollintoview (is automagical in WW) Part 3 Entirely different logic. again you can either use if/else based on 'if $webdriver' or just switch from the old to the new if you don't want to be cross compatible a) Window/Browser changing stuff Watir: Watir::IE.Attach(how, what) => WW: browser.window(how,what),use Watir: browser.close => WW: browser.window.close b) Javascript popup stuff (see http://stackoverflow.com/a/8172888/409820 ) Watir: some _no_wait method followed by browser.javascript_dialog.button.click WW: wrap one of the following around the action that causes popup browser.alert do #cause of alert popup end #=> "the alert message" browser.confirm(true) do #cause of confirm (set 'true' above to false to not confirm) end #=> "the confirm message" browser.prompt("hello") do #cause of prompt. #replace 'hello' above with user input in response to prompt end #=> { :message => "foo", :default_value => "bar" } If you find more (or if anyone else wants to add to the list) please feel free to update this and repost. (or add to the watir wiki) On Dec 29, 2:34 pm, Lisa Crispin <lisa.cris...@gmail.com> wrote: > We have Watir 1.6.2 and Ruby 1.8.6. We have MANY Watir/Test/Unit scripts > which we (well, I) mainly use to help with exploratory testing, and to > verify releases. I can't live without these scripts, so I don't want to > break them. At the same time, I want to try the latest Watir and Webdriver > to see if it correctly interprets the JS that our new Dojo code has - the > version of Watir we have can't cope with it, and Canoo WebTest/HtmlUnit > also cannot correctly interpret it. > > I perused the latest install instructions and info about the later Watir > releases, and it sounds like our older Watir scripts aren't going to work > with the later version? Is this true? How much effort is required to fix > them? Is there a central location with this information that I just haven't > found yet? > > If I install the latest Ruby and Watir/WebDriver, and our scripts don't > work, can I back up to the old versions again? > > I only spend about 10% of my time doing any sort of coding, so though this > might all be really obvious to y'all, it is something quite challenging and > scary for me. I would hate to abandon Watir and the excellent scripts we > have, but I don't get any support from my team on this. They are keen to > try Selenium. > > Thanks, > Lisa > > -- > Lisa Crispin > Co-author with Janet Gregory, _Agile Testing: A Practical Guide for Testers > and Agile Teams_ (Addison-Wesley 2009) > Contributor to _Beautiful Testing_ (O'Reilly 2009)http://lisacrispin.com > @lisacrispin on Twitterhttp://entaggle.com/lisacrispin -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. watir-general@googlegroups.com http://groups.google.com/group/watir-general watir-general+unsubscr...@googlegroups.com