Selenium (It’s Not Just for Testing!) App

At December’s San Francisco Selenium Meet-Up, I gave a “Lightning Talk” on a Selenium app I had developed in order to fulfill a customer request to upload hundreds of advertising campaigns using csv input rather than the customer’s fingers! (For those of you who missed the Meet-Up, Sauce Labs has posted video of all the Lightning Talks that evening on their blog.)

In January, that same customer came back with a new batch of advertising campaigns he wanted uploaded via my app. After taking a look at his csv, I noticed an issue. The cells in his csv’s column for maximum number of serves per day all contained 20, while the drop-down used to set that maximum number of serves on the site’s create-campaign page had a minimum option of 100. My Selenium app could not select an option that didn’t exist!

However, even though one could not create a campaign with fewer than 100 maximum serves per day, one could edit a campaign to be served fewer than 100 (by entering the corresponding dollar amount into a field on the Campaign Report Page).

While no mortal would want to do this task for hundreds of campaigns, a Selenium app could easily manage it. Less than 50 lines of Selenium-RC/Perl code were required, the core of which follows:


my $rows_processed = 0;
while ($rows_processed < $bottom_row) {
 $sel->click_ok("//input[\@value='Edit Options >']");
 $sel->type_ok("daily_budget_id", $new_daily_max);
 $sel->wait_for_text_present_ok("regexp:Daily Budget.*$new_daily_max.00",TIME_OUT);
 $sel->click_ok("link=< Back to Dashboard");

If the code looks like it’s always operating on the same row, that’s because it is. The dashboard always displays the most recently edited campaign at the top. Thus, the program starts with the $bottom_row campaign, which after editing, bounces to the top. The program again edits the $bottom_row campaign. After $bottom_row iterations, the app is done.

Here’s a very short demo that modifies just two campaigns. One campaign is changed from 100 Max/Day to 60, while the other is changed from 2000 Max/Day to 60.


About Mary Ann May-Pumphrey

I'm a software QA automation engineer, focusing primarily on Selenium/Webdriver automation of the front end of web apps. View all posts by Mary Ann May-Pumphrey

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: