Highlighted
Absent Member.. Absent Member..
Absent Member..
2991 views

web_reg_sa​ve_param_r​egexp in Vugen

This is a crosspost, as I initially posted in the incorrect forum...

 

I'm having an issue using web_reg_save_param_regexp in Vugen. I need to grab the "href" parameter from the following HTML code:

 

    <a href="/some/url/here/">
    
        <img src="/some/other/url/here.gif" border="0" align="absmiddle"/>
    Foo</a>

  

I have found this href parameter to be anywhere from the second to the fourteenth on the page, so using "ORDINAL=" to find the position doesn't work. As a result, I elected to use web_reg_save_param_regexp.

 

According to the web_reg_save_param_regexp reference in Vugen, a valid Perl regex will work in this function. I've built and tested the following regex, which correctly extracts the URL I'm looking for:

 

/href=\"(.+)\">.+Foo<\/a>/si

 

 

However, when I insert the following code into Vugen, it complains that the specified parameter can't be found:

 

web_reg_save_param_regexp("ParamName=Correlation1",
                          "RegExp=<a href=\"(.+)\".+Foo<\/a>",
                          LAST);

  

I assume that this is because the source HTML in the page spans multiple lines, but there does not appear to be an equivalent to Perl's "s" flag, which allows the regex to span multiple lines.

 

Unfortunately, the href is dynamicly generated each time the application runs, so I can't just hardcode it, and I am not the author of the webpage, so glomming all this together into one line in the page source is not an option.

 

Help? Am I missing flags for this function? Is there a better way to do this with a different web_reg_save_param_* function?

 

Thanks.

 

 

P.S. This thread has been moved from Application Perf Mgmt (BAC / BSM) Support and News Forum to LoadRunner Support Forum. -HP Forum Moderator

 
Tags (1)
0 Likes
3 Replies
Highlighted
Absent Member.. Absent Member..
Absent Member..

Re: web_reg_sa​ve_param_r​egexp in Vugen

Also, FWIW, in trying to use web_reg_save_param_xpath I can't even extract a single parameter based on XPath!

 

When I test the code code ...

 

web_reg_save_param_xpath("ParamName=Correlation1",
                         "QueryString=//a[1]/@href",
                         SEARCH_FILTERS,
                         "Scope=Body",
                         LAST);

 ...it should extract the href of the first <a> tag on the page, but it doesn't. The code:

web_reg_save_param_xpath("ParamName=Correlation1",
                         "QueryString=//a[contains(.,'Foo')]/@href",
                         SEARCH_FILTERS,
                         "Scope=Body",
                         LAST);

 ...should extract the href of the 'Foo' link from above, but again it doesn't.

 

What am I doing wrong?

0 Likes
Highlighted
Absent Member.. Absent Member..
Absent Member..

Re: web_reg_sa​ve_param_r​egexp in Vugen

For correllating my current HTTP script for an SAP Web application I ran into a ton of trouble with the traditional LB/RB approach of web_reg_save_param_ex, and decided to dive in to regexp as a whole. After beating my head against a wall for a bit, I noticed in the documentation's examples the authors are actually double-escaping anything that is a literal or is an escape char that needs to stay there.

 

Here's an exampl e. I had retreive the mangled string in the center of the below url from the server's response body.

 

?application_list[1].exit_url=/sap(bD1lbiZjPTQwMCZkPW1bg==)/bc/bsp/sap/crm_ic/default.htm 

 

 

web_reg_save_param_regexp(
  "ParamName=corSapShortUrl",
  "RegExp=application_list\\[1]\\.exit_url=/sap\\((.*)\\)/bc/bsp/sap/crm_ic",
  "Ordinal=1",
  SEARCH_FILTERS,
  "Scope=Body",
  "IgnoreRedirections=No",
  LAST);

In order for the escaped literals to remain escaped according to compiler, you have to escape the escape marks. It can get a bit silly in some cases. Here is another example below.

 

/*
8_V27_admini_table[1].unit\\" class=\\"sapDdlWhl\\"><option value=\\"CON\\" selected>?alsotry~ "RegExp=table\\[[0-9]+?\\]\\.unit\\\\\" .+?\\<option value=\\\\\"([A-Za-z]+?)\\\\\" selected\\>",
*/
    web_reg_save_param_regexp(
        "ParamName=Material1Unit",
        "RegExp=admini_table\\[1\\]\\.unit\\\\\" .+?><option value=\\\\\"([A-Za-z]+?)\\\\\" selected>",
        SEARCH_FILTERS,
        "Scope=Body",
        "IgnoreRedirections=No",
        LAST);

 

 I admit that these regular expression strings look like they could be overkill for what I'm trying to capture. They work though!

 

Hope this helps!

-Chris
0 Likes
Highlighted
Regular Contributor.
Regular Contributor.

Re: web_reg_sa​ve_param_r​egexp in Vugen

To correlate multi-line dynamic parameters, after several hours of trials, the following worked for me. It uses nested paranthesis to capture each line that could end with newline. It grabs the value that could be up to 200 lines, which you can adjust.

 

 web_reg_save_param_regexp(
  "ParamName=correlation_SAMLResponse",
  "RegExp=NAME=\"SAMLResponse\" VALUE=\"((.+\n?){1,200})\"/>",
  "Ordinal=1",
  SEARCH_FILTERS,
  "Scope=Body",
  "IgnoreRedirections=No",
  "RequestUrl=*/<selected-page>*",
  LAST);

 

The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.