During my load test, I would like to fetch values from an SQL database. How can I achieve this on load runner TrueClient protocol using JavaScript?
This would be great help…
During my load test, I would like to fetch values from an SQL database. How can I achieve this on load runner TrueClient protocol using JavaScript?
This would be great help…
Important: This will only work in TruClient (IE) and not in TruClient (Firefox).
Enter a new "Eveluate Javascript" step, and edit the javasctipt like so:
var connection = new ActiveXObject("ADODB.Connection") ;
var connectionstring="Data Source=<server>;Initial Catalog=<catalog>;User ID=<user>;Password=<password>;Provider=SQLOLEDB";
connection.Open(connectionstring);
var rs = new ActiveXObject("ADODB.Recordset");
rs.Open("SELECT * FROM table", connection);
rs.MoveFirst
while(!rs.eof)
{
// Here you should get the value from the 1st cell, 1st column
var value = rs.fields(1);
rs.movenext;
}
rs.close;
connection.close;
There are several options. I'll list them in order of their complexity:
Option 1: Use a parameter file to hold all of your data. If you need to modify it periodically, consider placing it in a shared location, accessible for all LGs.
Option 2: Use the Virtual Table Server (VTS) provided with LoadRunner. It is dedicated to sharing test data between virtual-users. Queries are easy with a built in API.
Option 3: You could write a custom C function, using LoadRunner DB API to query the DB, calling the function from your script using an Eval C step. Note this can only be done in VuGen.