Last active
December 14, 2015 15:59
-
-
Save onthespotqa/5112119 to your computer and use it in GitHub Desktop.
Example Watir Script, used during an sd-ruby talk.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'watir' | |
#Start the Browser | |
b = Watir::Browser.new | |
b.bring_to_front | |
b.maximize | |
#Go to the Watir Examples Form | |
b.goto 'http://bit.ly/watir-example' | |
#Set the Name text field | |
b.text_field(:name => 'entry.0.single').set 'Watir Demo' | |
#Set the What is your story? text box | |
b.text_field(:name => 'entry.1.single').set "This is a demo for SD Ruby \n This is a scripting demo." | |
#Set the What testing tool do you like? radio button | |
b.radio(:value => 'Watir').set | |
#Set the What language do you like? checkbox | |
b.checkbox(:value => 'Ruby').set | |
#Set the What browser do you use? select list | |
b.select_list(:name => 'entry.6.single').select 'Firefox' | |
#Submit the Form | |
b.button(:name => 'submit').click | |
#Returns true if the form submits successfully | |
puts b.text.include? 'Your response has been recorded.' | |
#Returns true if the the Page Title equals Thanks! | |
puts b.title == 'Thanks!' | |
b.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment