Quantcast
Channel: All LoadRunner Practitioners Forum posts
Viewing all articles
Browse latest Browse all 12134

Re: dynamic input to be chosen from drop down

$
0
0


First of all: If you want to make life easier on yourself, change that correlation a bit, so that you capture a single list containing all the relevant data for the chosen person in a single item.

So you get this:

CorrelatedValue_1 = "11111<random_HTML ... more random HTML>AAAAAA - LastName1, FirsName1"
CorrelatedValue_2 = "222222<random_HTML ... more random HTML>BBBBBB - LastName2, FirstName2"
.. etc.

We really don't care for that random HTML in the middle, but saving it probably won't hurt us a lot and it will make this easier since we now only have a single list of items to deal with and all of them look the same.

From there, this is actually an easy problem. I use ylib for this, so I will explain it using those functions, but you can probably get the same effect without it with a little bit of C glue code.

Doing it with y-lib involves these steps:


First, we choose a random element from the correlated values:

y_array_pick_random("CorrelatedValue");

That will save the chosen value in a parameter named "CorrelatedValue".

Second, we split that parameter into it's constituent parts:
y_left("CorrelatedValue", "<RandomHTML", "prop");
y_right("CorrelatedValue", "RandomHTML>", "propobj");

These two functions will basically save the part to the left of your random HTML into the "prop" parameter, and the part to the right of your random HTML into the "propobj" parameter.

Note that the "RandomHTML" thing is basically the right and left boundary of the correlation, just as you would have in a normal web_reg_save_param() call.

 

And that's basically the entire hat trick. Three easy function calls and a bit of smarts when it comes to capturing your input is all it needs.


Documentation for y_left() and y_right() can be found here:
http://randakar.github.io/y-lib/y__string_8c.html#abced95074b83aebcfb1454f15890c2b5
http://randakar.github.io/y-lib/y__string_8c.html#a8fa8cb819a971b562b07cf9ab9c84bba

 

Here is the documentation to y_array_pick_random():
http://randakar.github.io/y-lib/y__param__array_8c.html#a5df2b7be76beae12d6810e49f0f4bb8b


Note that you'll need to put y-lib into your script first. Doing that is easy: Download the files from github (link is in my sig), right-click on extra files, choose "add files to script", and use that to add the ylib files.

Then simply add the following line at the top of vuser_init:

 

#include "y_lib.c"

 

Done.


Viewing all articles
Browse latest Browse all 12134

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>