views:

153

answers:

2

Hi All,

I am working with Selenium in order to create load balancing tests on a web server. The website has a username/password and in order to work with this I have a csv file filled with username password combinations.

The issue is I am using the random function in Javascript to select a row from the csv file and populate the login functionality or registration details.

var csv = browserMob.getCSV("pickStickEmails.csv");
var row = csv.random();
var Email = row.get("email");
var Password = row.get("password");

selenium.type("ctl00_StandardMainBodyPlaceHolder_ctl00_TextBoxEmail", Email);
selenium.type("ctl00_StandardMainBodyPlaceHolder_ctl00_TextBoxEmailConfirm", Email);
selenium.type("ctl00_StandardMainBodyPlaceHolder_ctl00_TextBoxPassword", Password);
selenium.type("ctl00_StandardMainBodyPlaceHolder_ctl00_TextBoxPasswordConfirm", Password);

This obviously brings up issues when registering if the same record is selected twice during a scheduled run. Obviously with the login situation if a record isn't selected when registering and is then selected on a test that requires an existing account the test fails due to it not existing.

My question is, is it possible to somehow get browserMob to iterate through the records one at a time? Obviously when browserMob begins a load test it ramps up to lets say 10 users using the website at one time each running the script I assume?

I did write the test using Selenium-RC in C# with NUnit and read the csv file into a List and then iterated through the list. Obviously this runs each user after another and doesn't simulate multiple users being on the site at one time.

Any advice on this would be greatly appreciated.

Thanks,

Jon

+3  A: 

To enforce unique parameterization you need to call browserMob.getUserNum() as that will get the user number for that node that is processing your test. You can see this in their help. I have updated your code to how I think it should look. Should means I have not tested it :)

var csv = browserMob.getCSV("pickStickEmails.csv");
var row = browserMob.getUserNum();
var Email = row.get("email");
var Password = row.get("password");

selenium.type("ctl00_StandardMainBodyPlaceHolder_ctl00_TextBoxEmail", Email);
selenium.type("ctl00_StandardMainBodyPlaceHolder_ctl00_TextBoxEmailConfirm", Email);
selenium.type("ctl00_StandardMainBodyPlaceHolder_ctl00_TextBoxPassword", Password);
selenium.type("ctl00_StandardMainBodyPlaceHolder_ctl00_TextBoxPasswordConfirm", Password);
AutomatedTester
I looked at the BrowserMob Documentation and they use that function when referencing an array:var usernames = ['joe', 'meg', 'pat', 'chris', 'rob', 'beth'];var username = usernames[browserMob.getUserNum()];It seems along the right lines however var row = browserMob.getUserNum() has no reference to the CSV variable created on the line before meaning its not selecting anything. I've tried passing the csv file as an arguement to getUserNum, and csv.getUserNum both to no avail any ideas?
Jonathan Stowell
A: 

I think this could possibly be a way to get a unique record for each user during a load test:

var csv = browserMob.getCSV("pickStickEmails.csv");

var rowNumbers = new Array();
for(i = 0; i <= csv.size(); i++)
{
  rowNumbers.push(i);
}

var uniqueRowNumber = rowNumbers[browserMob.getUserNum()];
var row = csv.get(uniqueRowNumber);

var Email = row.get("email");
var Password = row.get("password");

selenium.type("ctl00_StandardMainBodyPlaceHolder_ctl00_TextBoxEmail", Email);
selenium.type("ctl00_StandardMainBodyPlaceHolder_ctl00_TextBoxEmailConfirm", Email);
selenium.type("ctl00_StandardMainBodyPlaceHolder_ctl00_TextBoxPassword", Password);
selenium.type("ctl00_StandardMainBodyPlaceHolder_ctl00_TextBoxPasswordConfirm", Password);

It basically creates an array of numbers which act as row numbers for the csv file. Then it just uses the get() function on the CsvTable instead of random using the unique number selected from your suggestion.

Thank's for the guidance!

Jonathan Stowell