1

In HP Load Runner VU Gen, I'd like to white a script that reads data from a table, with multiple columns and use data to call some url, based on env.

I do have 2 tables with the same structure : mytable_dev and mytable_prod. Those are File paramaters tables. For example, in mytable_dev.dat: firstname | lastname | age john | Smith | 12 Lara | Croft | 24 ...

I can do something like this to get "dev" or "prod":

env = lr_get_attrib_string("env");

Then I can select the table (dev or prod) with:

sprintf (data_temp,"{url_imd_%s}", env);
lr_save_string (lr_eval_string(data_temp), "data_env");

Then I'd like to call some url, based on table values:

web_rest("Foo",
  "URL=http://somesite.com/foo/{data_env['firstname']}/{data_env['lastname']}",
  ...

How can I do that ?

Th.

thierryler
  • 147
  • 1
  • 14

2 Answers2

2

This is not how parameters work. Each parameter refers to a single column of the data table (see the Select Column -> By Name combobox). Parameter TestA is defined on the A column of the dataset in the file

Buzzy
  • 2,905
  • 3
  • 22
  • 31
0

I have a solution.

First, I use "table" parameter type, and not "file", named "date_dev". Here "dev" is the name of my environment. I also have "data_int", "data_prod", etc.

fw_save_format_eval_string("{ENV}", "{data_%s}", "DATAS_ENV");
temp = lr_eval_string("{DATAS_ENV}");
fw_splitlist_paramarr(temp, "PARAMETRE", ";");

Here ";" is my CSV separator.

And the function that does the work:

int fw_splitlist_paramarr(char *in, char *out_param, char *sep)
{
int i = 0;
char *p, *t, paramName[PARAM_SIZE];

sprintf(paramName, "%s_count", out_param);
lr_free_parameter(paramName);
lr_save_int(i, paramName);

if ((p = strdup(in)) == NULL)
{
lr_free_parameter(paramName);
return -1;
}
t = strtok(p, sep);
while (t != NULL)
{
i++;
sprintf(paramName, "%s_%d", out_param, i);
lr_save_string(t, paramName);
t = strtok(NULL, sep);
}
free(p);

sprintf(paramName, "%s_count", out_param);
lr_free_parameter(paramName);
lr_save_int(i, paramName);
return 0;
}

Enjoy :-)

thierryler
  • 147
  • 1
  • 14