in , ,

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...
 
filename="numbers.csv"
CSV.foreach(filename, :headers => true) do |row|
 
  num = row.field(0)
  browser.text_field(:id=>"phone_number").set "#{num}"
  browser.send_keys :enter
  browser.td(:id=>"pop").click
  browser.select_list(:id=>"location").select_value("1")
  browser.tr(:class=>"first-row").checkbox.set
  browser.input(:id=>"submit").click
 
end

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.

Performance

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.

What do you think?

0 points
Upvote Downvote

Total votes: 0

Upvotes: 0

Upvotes percentage: 0.000000%

Downvotes: 0

Downvotes percentage: 0.000000%

Written by Admin

I work for a Telecom company writing and testing software. My passion for writing code is expressed through this blog. It's my hope that it gives hope to any and all who are self-taught.

Comments

Leave a Reply

Loading…

Automating SEO, Link and Page Validation

Basic Linux: Finding and Locating things