SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Page 1 of 2 12 LastLast
Results 1 to 10 of 11
  1. #1
    SQA Knight
    Join Date
    Jul 1999
    Location
    Grand Rapids, MI
    Posts
    3,727
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    web_reg_save_param_regexp() questions

    Just when I am foolish enough to think I understand regular expressions something comes along to put me in my place. I have two questions for those who know how to boss around regular expressions in vuGen 11. The BODY text being returned for both of my questions is:

    var data = "App.XD._scbs.f593bfb3ce8ce7\\x2D\\x7B\\x0A\\x20\\ x20\\x22 <font color="blue"> status</font>\\x22\\x20\\x3A\\x20<font color="blue">200</font>,\\x0A\\x20\\x20\\x22callid\\x22\\x20\\x3A\\x 20<font color="brown">100410100</font>,\\x0A\\x20\\x20\\x22userid\\x22\\x20\\x3A\\x 20\\x226cf0225c\\x2Dd80f\\x2D48a0\\x2D939c\\x2Dd25 40702136e\\x22,\\x0A\\x20\\x20\\x22 <font color="green">state</font>\\x22\\x20\\x3A\\x20\\x22 <font color="green">SUCCESS</font>\\x22\\x0A\\x7D";\n

    1. Extracting the <font color="blue">status</font> value. This is the only regEx expression that I can get to extract the status number <font color="blue">200</font>:

    "RegExp=status.*x20([0-9]+),.*call"

    I initially thought I could use: "RegExp=status.*x20([0-9]+),"

    But when I used that regEx pattern it returns the <font color="brown">100410100</font> value. Now that also qualifies for this regEx pattern but I am surprized that LR returns the last match rather than the first (which is how the older functions worked). I tried to use the Perl interval construct, but it has no positive effect (but using it did not throw a runtime error):

    "RegExp=status.*x20([0-9]+),{1}" and "RegExp=status.*x20([0-9]+){1},"

    So is there a way to construct a regEx pattern to select a specific occurance of the match, when there is more than one match in the Body?

    2. Extracting the <font color="green">state</font> value. All of the following regEx expressions extract the state string <font color="green">SUCCESS</font>:

    a. "RegExp=state.*x22([a-zA-Z_]+)"
    b. "RegExp=state.*x22([a-zA-Z_]+)\\.*"
    c. "RegExp=state.*x22([a-zA-Z_]+)\x5C.*"
    d. "RegExp=state.*x22([a-zA-Z_]+)\134.*"

    Now 2(a) is the cleanest, but I like an explicit RB anchor. But I get the following error for b, c, and d when the pattern does not end with (what seems to me unnecessary as per my O'Riely book on RegEx) the .* character combination:

    <font color="red">Error -35055: Invalid regular expression [MsgId: MERR-35055]</font>

    So why is "RegExp=state.*x22([a-zA-Z_]+)<font color="green">\\.*</font>" a valid regEx pattern while "RegExp=state.*x22([a-zA-Z_]+)<font color="red">\\</font>" " is not?

    -Thanks, Terry Horwath

  2. #2
    Member LoadRunner421's Avatar
    Join Date
    May 2011
    Posts
    225
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: web_reg_save_param_regexp() questions

    I'm no expert but I've been using LR regex for a little while.

    This one worked for me to get the 200:
    Regex: status.{1,25}([0-9][0-9][0-9])

    I believe the key is the '{1,25}', assuming there is a pattern/format for how far away the '200' is from 'status'.

  3. #3
    Member
    Join Date
    Nov 2010
    Location
    MN, USA
    Posts
    60
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: web_reg_save_param_regexp() questions

    Hi Terry,

    The simple asnwer is that it is most likely the escaping of the "\" character and it is very very fussy. Play around with how many you use in order to get it to work. I had one RE that invovled the "\" character (for a file path name) and needed FOUR in a row..... I acually ran the RE through that wonderfully helpful Rubular website and it worked cleanly there. After reading and rereading and rereading the document over several times, I determined that the only thing it could have been was the escaping. After lining up 4 in a row, it suddenly worked so sweetly.

    Tom

  4. #4
    Member LoadRunner421's Avatar
    Join Date
    May 2011
    Posts
    225
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: web_reg_save_param_regexp() questions

    I actually realized you could also just do:

    status.{1,25}([0-9]{3})

  5. #5
    SQA Knight
    Join Date
    Jul 1999
    Location
    Grand Rapids, MI
    Posts
    3,727
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: web_reg_save_param_regexp() questions

    421,

    Thanks for this feedback. I was pondering your "status.{1,25}..." syntax (why 1?) and found that while LR says the BODY response is:

    t=24432ms: 842-byte chunked response body for "https://ptest-[redacted]/controller/api/widget/validatepu...
    &lt;html&gt;\n
    &lt;head&gt;\n
    &lt;/head&gt;\n
    &lt;body&gt;\n
    &lt;div id="root"&gt;&lt;/div&gt;\n
    &lt;script type="text/javascript"&gt;\n
    var data = "App.XD._scbs.f593bfb3ce8ce7\\x2D\\x7B\\x0A\\x20\\ x20\\x22status\\x22\\x20\\x3A
    \\x20
    <font color="blue">200</font>,\\x0A\\x20\\x20\\x22callid\\x22\\x20\\x3A\\x 20100410111,\\x0A\\x20\\x20\\x22useri
    d\\x22\\x20\\x3A\\x20\\x226cf0225c\\x2Dd80f\\x2D48 a0\\x2D939c\\x2Dd2540702136e\\x22,\\x0A\\
    x20\\x20\\x22state\\x22\\x20\\x3A\\x20\\x22SUCCESS \\x22\\x0A\\x7D";\n
    var xdUrl = "https\\x3A\\x2F\\x2Fptest\\x2Dstatic.v.me\\x2Fxdr .html";\n
    if (typeof window.postMessage != 'undefined') {\n
    parent.postMessage(data, xdUrl.split('/', 3).join('/'));\n
    } else if (xdUrl.indexOf(window.location.protocol) != 0) {\n
    window.name = encodeURIComponent(data); window.location.href = xdUrl;\n
    } else {\n
    document.getElementById("root").innerHTML = '&lt;iframe src="'+encodeURI(xdUrl)+'" name="'+en
    codeURIComponent(data)+'"&gt;&lt;/iframe&gt;';\n
    }\n
    &lt;/script&gt;\n
    &lt;/body&gt;\n
    &lt;/html&gt;\n

    In reality this relevant string within the BODY is actually being returned:

    &lt;html&gt;\n&lt;head&gt;\n&lt;/head&gt;\n&lt;body&gt;\n&lt;div id="root"&gt;&lt;/div&gt;\n&lt;script type="text/javascript"&gt;\nvar data = "App.XD._scbs.f593bfb3ce8ce7\x2D\x7B\x0A\x20\x20\x 22 status\x22\x20\x3A\x20<font color="blue">200,</font>\x0A\x20\x20\x22callid\x22\x20\x3A\x201004101 11,\x0A\x20\x20\x22userid\x22\x20\x3A\x20\x226cf02 25c\x2Dd80f\x2D48a0\x2D939c\x2Dd2540702136e\x22,\x 0A\x20\x20\x22state\x22\x20\x3A\x20\x22SUCCESS\x22 \x0A\x7D";\nvar xdUrl = "https\x3A\x2F\x2Fptest\x2Dstatic.v.me\x2Fxdr.html ";\nif (typeof window.postMessage != 'undefined') {\nparent.postMessage(data, xdUrl.split('/', 3).join('/'));\n} else if (xdUrl.indexOf(window.location.protocol) != 0) {\nwindow.name = encodeURIComponent(data); window.location.href = xdUrl;\n} else {\ndocument.getElementById("root").innerHTML = '&lt;iframe src="'+encodeURI(xdUrl)+'" name="'+encodeURIComponent(data)+'"&gt;&lt;/iframe&gt;';\n}\n&lt;/script&gt;\n&lt;/body&gt;\n&lt;/html&gt;\n

    The difference being that the Replay Log LR display is escaping the backslash characters, as in \\x22, etc.

    So once I figured that out I could then use the exact interval count of any char matches using this regEx statement: "RegExp=status.{16}([0-9]{3})". But my original regEx statement is a bit more flexible and does not depend on char counts. I would still like to construct a statment that logically says: get the FIRST pattern match of this: "RegExp=status.*x20([0-9]+)," but its proper regEx contruction still aludes me.

  6. #6
    Member LoadRunner421's Avatar
    Join Date
    May 2011
    Posts
    225
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: web_reg_save_param_regexp() questions

    Yes the 1 in the {1,25} is probably not necessary, I was just using a range that worked.

    I can see that you somehow know that "x20" is always in the string, so can't you find out how long the string is? Even if it's a range you can still use the curly braces to your advantage, unless the range is too big, then the second match will be picked up sometimes...

    I know what you're saying though about finding the first match, that would be a useful regex function, I wonder if it's out there...

  7. #7
    Moderator
    Join Date
    Jan 2006
    Location
    Charlotte, NC
    Posts
    1,600
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: web_reg_save_param_regexp() questions

    And now for something completely different...

    Why are you trying to do what you are trying to do?


    When I look at your input, the last thing I think is Regular Expression. I would step back and figure out what I really wanted to do and approach it completely differently.

    Yes, the above is my personal opinion, and yes, I DID NOT read this thread in detail.
    Unless you are writing a compiler, strtok is NOT the answer.
    See: http://www.sqaforums.com/showflat.ph...=541641#542222

    QAF is still an exercise in self-sufficiency! (Thank JB!)

  8. #8
    SQA Knight
    Join Date
    Jul 1999
    Location
    Grand Rapids, MI
    Posts
    3,727
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: web_reg_save_param_regexp() questions

    Russell,

    Well of course you can always be counted on to read a thread before diving in! [img]/images/graemlins/wink.gif[/img]

    So you would go after correlation of ...status\x22\x20\x3A\x20<font color="blue">num</font>,... using web_reg_save_param()? I did not mentioned that I have received 2 builds that return different BODY syntax (the first sent "...status : <font color="blue">num</font>..., while the latest build is returning URL compliant syntax).

    Now that I figured out that the LR Replay Log was escaping the \ chars I could go back and use web_reg_save_param() but web_reg_save_param_regex() seems more flexible in this situation.

    So I would like it if you would expand on your opinion here, as I can always use another experienced point of view when it comes to correlating values.

    -Thanks, Terry

  9. #9
    Moderator
    Join Date
    Jan 2006
    Location
    Charlotte, NC
    Posts
    1,600
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: web_reg_save_param_regexp() questions

    The escaping and levels of escaping are exactly why when I looked at your post I thought "YUCK!"

    In a case like this I want to get what I get and then work with a knife to cut it down. That way I can look at each cut I make and if it's not working back it out.

    -------------

    If different builds are changing what is returned then you need to recode. Everyone needs to understand that!
    Unless you are writing a compiler, strtok is NOT the answer.
    See: http://www.sqaforums.com/showflat.ph...=541641#542222

    QAF is still an exercise in self-sufficiency! (Thank JB!)

  10. #10
    Junior Member
    Join Date
    Feb 2008
    Posts
    24
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: web_reg_save_param_regexp() questions

    All,

    How to capture Sharath2Bode using LR9.5?
    ID=\x22Sharath2Bode\x22&gt;

    Can pls anyone suggest?

 

 
Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 10.00%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 10:19 AM.

Copyright BetaSoft Inc.