Sorry if this a repeat question; I didn't find an answer. (Yes, I checked, but I didn't RTFM for LR 11.04. I want to maintain what fleeting sanity I have left.)
I know it is possible to call Perl from within loadrunner, but haven't yet found an example. I know it is possible, because the RegEx logic in the Web_Reg_Save_Param_ex / Web_Reg-Save_Param_Regexp functions is ported out to Perl subroutines.
I need to know how to do that, as I have a fair number of things we need to do with the (half-@$$ed) applications we test.
Examples are:
.NET application - I could hunt down the parameter values quickly and easily, slice and parse them outside of LR, then return the values into LR.
Standard Web app - makes a third-party call to someone's sandbox. All info is in Base64 encoding. We need to get the plaintext (provided in response), then encode to Base 64, and send it to the primary system. So, AUT is System A; System A calls System B (302 response), System B responds, and the AUT sends that data back to Systam A to store in its database. (Since System A and System B are from same vendor - Well, I have my questions about our bidding process, but it's OT.)
I have an issue in that I'm a good programmer, but a noob at Perl. So I need to scavenge and re-write, more than just sit down and code at this point. I examined the RegEx info I could find (best so far was using regular expressions in loadrunner), but so far inadequate for what I'm trying to do.
Source:
{"text":"A*","value":"271"}, // This is just the pattern - it's repeated 320 times or so
Example code snippets:
web_reg_save_param_ex(
"ParamName=Charity1",
"LB={\"text\":\"",
"RB/RE=\",\"value\":\"([0-9]+)\"},",
"Ordinal=All",
SEARCH_FILTERS,
"Scope=Body",
"IgnoreRedirections=Yes",
"RequestUrl=*/Person.aspx*",
LAST);
That one works, returns the name (A*
from source above).
web_reg_save_param_ex(
"ParamName=Charity1",
"LB/RE={\"text\":\"([A-Za-z0-9].+)\",\"value\":\"",
"RB=\"},",
"Ordinal=All",
SEARCH_FILTERS,
"Scope=Body",
"IgnoreRedirections=Yes",
"RequestUrl=*/Person.aspx*",
LAST);
This does NOT work for me - total records found, ZERO. OK, one entry has a "-" in there, some have spaces - but a 100% failure? OTOH, if I could capture the whole list, I would then send it to Perl, split the substrings, and return two values trimmed and neat, to save as LoadRunner strings (I think - LR doesn't much like more than a single return value so far. But I could do a STRUCT and return the values to that, I think, or a pointer to the memory space and make LR read the refereced memory to a STRUCT, or something like that.)
Problem is, it's become obvious that the AUT uses both values right off, so I can't work with it later, when the value is sent back - and apparrently, the NUMBERS are what matter more than the text.
Any suggestions are appreciated, I want to avoid using system()
, though - that's the work-around I have for the Base64 question (it was supposed to be the ONLY Perl call, ever.) It worked GREAT... Until I added one of the M$
required patches, and could no longer open and read the file in LoadRunner (and HP said, It's custom code, we can't help you. So I removed the M$
patch and ran the test. It was a c++ Redistributable circa 2010. That was late 2012. For reference, we're still running XP in this shop. I have a Core i5 with 4 GB on my desk here... Shipped with Win7. And we're running Xtra Pathetic. Sanity is in short supply here …)
// ****** Late revisions:
Modifying the LoadRunner calls (to web_reg_save_param_regexp) worked after I got the RegEx's straightened out. Not clear why a "Not Quote" RegExp didn't return an A*
for the first value, but I found out why the 271
wasn't showing up - that was easy, actually. The end value didn't have the same boundary conditions. The first value, apparrently "Not Quote" doesn't include when there's a "*
" in the value. ???
web_reg_save_param_regexp(
"ParamName=Charity_REGEX",
"RegExp={\"text\":\"([^\"]{1,8})\",\"value\":\"",
"Ordinal=All",
SEARCH_FILTERS,
"Scope=Body",
"IgnoreRedirections=Yes",
"RequestUrl=*/Person.aspx*",
LAST);
web_reg_save_param_regexp(
"ParamName=Tenants_REGEX",
"RegExp=\",\"value\":\"([0-9]{1,3})\"}",
"Ordinal=All",
SEARCH_FILTERS,
"Scope=Body",
"IgnoreRedirections=Yes",
"RequestUrl=*/Person.aspx*",
LAST);