require 'firewatir' require 'time' include FireWatir require 'win32ole' $d = Time.now.strftime("%m/%d/%y%t,%I:%M:%S-%p,") def scriptlogcreate $scriptlog = File.new("OurCity.log", "w") $scriptlog.puts 'ScriptLog Initialized ' $scriptlog.puts '##Begin Test: ' end def fflaunch $ff = FireWatir::Firefox.new $scriptlog.puts "Firefox launched" end def spreadsheetinitialize $ts = File.new( "OurCity" + Time.now.strftime("%d-%b-%y") + "-Ruby" + ".csv", "a") $ts.puts "BUILD: " $ts.puts "URL" + "," + "Time by Calc in Secs" + ",DATE," + "TIME" $ts.puts " " $scriptlog.puts "Spreadsheet Initialized" end def gotourl(urlsample) $ff.goto(urlsample) $ff.maximize() $scriptlog.puts urlsample + "launched and maximised" end def pgdwnldtime timevar1 = $ff.down_load_time timevar1 = timevar1.to_s $scriptlog.puts "Page download time captured" return timevar1 end def timer timer = Time.now $scriptlog.puts "Timer Active Now!" return timer end def calctimer(starttime, stoptime) timetaken = (stoptime - starttime).to_s $scriptlog.puts "Time taken to download is calculated" return timetaken end def inputdata(url,timebycalc,date) $ts.puts url + "," + timebycalc + "," + date $scriptlog.puts "Data input done to the Output CSVfile" end def calcmethod line = '1' excel = WIN32OLE.new('excel.application') workbook = excel.workbooks.open('C:\TestingTools\RubyScripts\FF\List.xls') worksheet = workbook.Worksheets(1) worksheet.Select while urlis = worksheet.range("a#{line}")['Value'] #urlis = worksheet.range('a#{line}')['Value'] $scriptlog.puts "Url :" + urlis starttimer = timer gotourl(urlis) stoptimer = timer pgdwnldvar1 = pgdwnldtime #timebytimer = calctimer(starttimer,stoptimer) inputdata(urlis,pgdwnldvar1,$d) line.succ! end end