Web Automation with CSV Imports

I had a real life request at work the other day.  My boss had a goal of migrating some phone numbers to different POPs.  In fact he had a large list – 4,000+ numbers.  The carrier in question only had a web interface for this task (no API) and the web interface would only take one number at a time.  The carrier’s website was slow, taking about 10 seconds for time to find a number in the system, mark for moving to a new POP and moving it.

He asked me if we could automate this.

I look at the site and it was fairly simple. So I wrote a one off script to automate the carrier’s website, and run all the functions he would run as a end user migrating each phone number.  Then we worked together to get the gigantic list of numbers imported.  He output his Excel data s a CSV file with no header.  Then in the code we reworked the automation so it went like this:

require 'csv'
# bunch of watir code to login and get to the form page...
CSV.foreach(filename, :headers => true) do |row|
  num = row.field(0)
  browser.text_field(:id=>"phone_number").set "#{num}"
  browser.send_keys :enter

The above code worked out great. It loaded each each line of the CSV file, one by one, and took the value for the field.  Since it was a one value row, it was easy.  Then we pushed that value into the website’s form field for phone number.  Using send_keys, we hit enter and it finds the phone number in the database.  Next we click a tab called Pop and then change the location for this number from a dropdown list.  We check the checkbox to confirm this number for migration and click the submit button.


In a perfect world, the carrier would have an API, or a form that would take a list of values.  In the REAL world however, you don’t have that luxury.  The team even tried tow work with the carrier to have them input all 4,000 numbers on their end.  They refused.  Outside of manually eating up hours of data input, this automated solution did all the work.

But it was slow.  The gain was that a human didn’t have to absorb the time commitment.

Web Automation with CSV Imports
User Rating: 0 (0 votes)