Highlighted
anirudhb Absent Member.
Absent Member.
5719 views

Using regex in web_reg_save_param boundaries

Hi all,

 

I am trying to write a script which will pick up a dynamic value from a drop down menu and submit it to go to the next page. The HTTP response looks like this:

 

\t\t\t\t\t<option value="Rose taupe" id="WD26" class="WD26">Rose taupe</option>\n

\t\t\t\t\t<option value="Myrtle" id="WD20" class="WD20">Myrtle</option>\n

\t\t\t\t\t<option value="Deep carmine pink" id="WD142" class="WD142">Deep carmine pink</option>\n \t\t\t\t\t<option value="Wild Strawberry" id="WD66" class="WD66">Wild Strawberry</option>\n

\t\t\t\t\t<option value="Cream" id="WD72" selected="selected" class="WD72">Cream</option>\n

\t\t\t\t\t<option value="Tangerine yellow" id="WD94" class="WD94">Tangerine yellow</option>\n

 

I want to pick up the color that is selected in a drop down menu in the front end, in the response this color line has selected="selected" in it. This is however random for each instance hence the regex has to pickup the color name from the line which contains selected="selected".

 

I tried using web_reg_save_param_regexp with the regular expression <option value="([^"]*)" id="[^"]*" selected="selected but there are two dynamic values i.e. value and id.

 

I want to use a simple web_reg_save_param where I can use regex in the boundaries so as to pick up the color name from the response. So far what I have is:

 

    web_reg_save_param_ex("ParamName=SelectedColor", 
    "LB/IC=\t\t\t\t\t<option value=\"",
    "RB/ALNUMIC=\" id=\"[^\"]*\" selected=\"selected\"",
    "Ord=all",
    "Search=body",
    LAST);

 

OR


    web_reg_save_param_ex("ParamName=SelectedColor", 
    "LB/ALNUMIC=selected=\"selected\" class=\"[^\"]*\">",
    "RB/IC=</option>\n",
    "Ord=all",
    "Search=body",
    LAST);

 

However this gives me an error Action1.c(73): Error -26396: The "RB/ALNUMIC=" id="[^"]*" selected="selected"" argument (number 3) is unrecognized or misplaced   [MsgId: MERR-26396].

 

Can anyone please help me in using regex in the boundaries for this function? Thanks a lot, and kindly let me know if more details are needed!

0 Likes
2 Replies
yangyan Frequent Contributor.
Frequent Contributor.

Re: Using regex in web_reg_save_param boundaries

Hi,

 

The correct argument should be "RB/RE", "RE" stands for regular expression.

Like this:

 

web_reg_save_param_ex(
        "ParamName=SelectedColor",
        "LB=<option value=\"",
        "RB/RE=\" id=\"[^\"]*\" selected=\"selected\"",
        SEARCH_FILTERS,
        "Scope=Body",
        LAST);

 

or


web_reg_save_param_ex("ParamName=SelectedColor", 
    "LB/RE=selected=\"selected\" class=\"[^\"]*\">",
    "RB/IC=</option>\n",
    "Ordinal=all",
    SEARCH_FILTERS,
    "Scope=Body",
    LAST);

 

Regards,

Ellie

0 Likes
Honored Contributor.. Naveen_KumarN Honored Contributor..
Honored Contributor..

Re: Using regex in web_reg_save_param boundaries

Re-record with the option to record non HTML-generated elements in seperate steps and use concurrent groups.


Thank you,
NaveenKumar Namachivayam | www.QAInsights.com
Learn TruWeb - my Udemy Course "Performance Testing using TruWeb" | https://www.udemy.com/performance-testing-using-truweb/?couponCode=YOUTUBE
0 Likes
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.