For this Sunday’s weekend testing session, Oliver introduced the group to a web test automation tool called Watir which works with Ruby. I also found out that this session will be a precursor for yet another session for a test automation tool called Cucumber but the next session will be four weeks away though. I’m digressing. Anyways, as a prerequisite (supposedly), we were asked to install ruby and watir onto our workstations following instructions laid out in http://watir.com/installation/#win.
The session started off with Oliver walking us through with some basic commands, then afterwards he let us work on our own on a mission to use watir for posting a forum reply in weekendtesting.com. I had some trouble at first. For one, when I worked with IE7, one of the commands (
b.text.include? "<text>") just kept returning
false. I’m guessing watir was still looking at the blank tab rather than at the tab where the test web page was launched. I then tried using Firefox instead but I was getting an error message on jssh even though I’ve just installed the plug-in as indicated in the watir installation site. I later realized that I had two versions of Firefox and the command
Watir::Browser.new seemed to be opening the older one which didn’t have the plug-in installed. After getting that sorted out, it was pretty much smooth sailing. :)
Here’s a summary of commands I used in the session:
require "watir" Watir::Browser.default = "firefox" b = Watir::Browser.new b.goto("http://weekendtesting.com") # Find text b.text.include? "Forum" # Click links b.link(:text, "Forum").click b.link(:text, /Next Weekend/).click # Log in b.text_field(:id, "user_login").set "<username>" b.text_field(:id, "user_pass").set "<password>" b.button(:value, "Log In").click # Post a reply for the WTANZ07 topic # Would only work if the topic is still in the list of Ongoing Discussions # Searching for "WTANZ session #07" didn't work (even thru manual approach) b.link(:text, "Forum").click b.link(:text, /WTANZ session.*07/).click b.link(:text, "Reply").click b.text_field(:name, "message").set("Test reply yada yada blah blah") b.button(:value, "Submit").click # Log out b.link(:text, /Logout/).click
Right after the session, I found some more links on watir to check out later when I have time. :p