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.goto(url)
ie.text_field(:name,'txtUsername').set 'nicks'
ie.text_field(:id,'txtPassword').set 'xxxxxxxx'
ie.button(:id,'btnLogon').click
end

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

ie = Watir::Browser.new
Login(url, ie)

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

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 →

JK Vine in the news regarding Compuware Partnership

ComputerWorld
http://www.computerworld.com.au/mediareleases/19633/jk-vine-consulting-joins-the-compuware-apm/

CMO

http://www.cmo.com.au/mediareleases/19633/jk-vine-consulting-joins-the-compuware-apm/

ITWire

http://www.itwire.com/it-industry-news/market/64442-jk-vine-joins-compuware-apm-partner-program

CIO

http://www.cio.com.au/mediareleases/19633/jk-vine-consulting-joins-the-compuware-apm/