Examples
All examples are designed to work on the live Watir demo form: .Loading RubyGemsIf you’re a first time Ruby user, you need to understand how to load Ruby gems such as Watir. You can require it via the -rubygems command line option or by using the RUBYOPT environment variable. You can also require it manually in your script:require 'rubygems' For more information .Including Watir gem to drive Internet Explorer on Windowsrequire 'watir'Including gem to drive Firefox/Chrome on Windows/Mac/Linuxrequire 'watir-webdriver'Starting a new browser & and going to our sitebrowser = Watir::Browser.newbrowser.goto 'http://bit.ly/watir-example'Setting a text fieldbrowser.text_field(:name => 'entry.0.single').set 'Watir'Setting a multi-line text boxbrowser.text_field(:name => 'entry.1.single').set "I come here from Australia. \n The weather is great here."Setting and clearing a radio buttonbrowser.radio(:value => 'Watir').setbrowser.radio(:value => 'Watir').clearSetting and clearing check boxesbrowser.checkbox(:value => 'Ruby').setbrowser.checkbox(:value => 'Python').setbrowser.checkbox(:value => 'Python').clearClicking a buttonbrowser.button(:name => 'logon').clickClearing, getting and selecting selection list valuesbrowser.select_list(:name => 'entry.6.single').clearputs browser.select_list(:name => 'entry.6.single').optionsbrowser.select_list(:name => 'entry.6.single').select 'Chrome' Clicking a buttonbrowser.button(:name => 'submit').clickChecking for text in a pageputs browser.text.include? 'Your response has been recorded.'Checking the title of a pageputs browser.title == 'Thanks!'more info: