Ruby WATIR easy browser automation

I needed to run 100 accounts through on 6 different URLs and record end user response times. In less than 30 lines of code Ruby WATIR did the job for me.

require 'thread'
require 'watir'

url     = ARGV[0]
acc_in     = ARGV[1]
log_out = ARGV[2]

def Login(url, ie)
ie.text_field(:name,'txtUsername').set 'nicks'
ie.text_field(:id,'txtPassword').set 'xxxxxxxx'

def search_account(accnum, ie, log_out)
ie.frame(:id, 'iFMain').text_field(:id,'txtAccNumber').set accnum
start =
ie.frame(:id, 'iFMain').button(:id,'btnDisplay').click
diff = - start, 'a') do |f2|
f2.puts "#{start} , #{diff},  #{accnum.strip} "

ie =
Login(url, ie)

IO.foreach(acc_in) do |line|
search_account(line, ie, log_out)

Join us at next CMGA _ Nick Singh is speaking 06/08/14

CMG Australia Meetup, August 6th 2014

Wednesday, Aug 6, 2014, 5:45 PM

The Apartment
401 Little Bourke Street Melbourne, AU

43 CMGites Went

Team,IBM has offered to host the next CMG Australia Meetup. Light refreshments (Beer, Pizza, etc.) will be provided. The August 2014 meetup will be held at The Apartment. Details for the meetup are provided below:Guest Speaker : Annie Lin on Measuring Performance Early On: Service Virtualization To The RescueAbstract : Most systems being built …

Check out this Meetup →