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)

Using the AWS Ruby SDK to launch and tag AWS EC2 Spot Requests

Amazon Web Services provide a number of SDKs that support the various scripting languages. Because we love to automate manual repetitive tasks, we utilized the Ruby AWS SDK to develop a script that: –

1. Creates a specified number of spot instance requests with associated launch parameters
2. Spreads the launch requests over a specified number range of launch zones
3. Waits for the instances to be fulfilled and informs you
4. Tags the instances with your tagname so they appear with a visible description in the web portal name

This is a working version but feel free to enhance to parameterise obvious variables
Continue reading

Using Ruby to connect to DB2 and extract data to a CSV

Well the young boys keep raving about Ruby. I still think Python has a lot more library support via eggs because it has been around longer. Anyhow I gave Ruby a crack for this trivial task and, yes, the same as Python, it does’nt take too much code to automate a painful manual task.

This little script, runs on windows. It will connect to a remote IBM DB2 database, execute a query, then output the result set to a CSV file. You will need some prerequisites before you can do this. Before you continue for this you will need a DB2 client installed, although not the full DB2 client is needed you can download and install the appropriate IBM Data Server Driver for ODBC/JDBC and CLI from here IBM DataServer drivers. If you already have DB2 client software installed then dont worry about this.

Continue reading