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,730
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    correlate with local vars?

    My profile:
    http://www.sqaforums.com/showflat.ph...;Number=401269

    I have this chunk of recorded code that I want to place in a for loop and interate through report pages:

    web_url("ViewPage_2",
    "URL=https://www.XXX.{platform}/...page=2&...actor=100",
    ...
    "Snapshot=t1138.inf",
    "Mode=HTML",
    LAST);

    So I now have a integer variable, nextPage that I want to use in the loop replacing the harcoded =2 above. But how do I syntactically do this? {nextPage} does not work as LR appears to be looking for, and not find, a parameter.

    -Thanks, Terry Horwath

  2. #2
    Senior Member
    Join Date
    Aug 2003
    Location
    Atlanta
    Posts
    777
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: correlate with local vars?

    Hello Terry,

    Could you save it into a parameter and use lr_param_increment to increment the value as needed?

    That way you could use it in the URL as a parameter

    <font class="small">Code:</font><hr /><pre>
    "URL=https://www.XXX.{platform}/...page={nextPage}&amp;...actor=100",
    </pre><hr />

    Hope this helps [img]/images/graemlins/grin.gif[/img]
    -Terri

  3. #3
    Advanced Member
    Join Date
    Jun 2006
    Location
    USA
    Posts
    785
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: correlate with local vars?

    lr_save_sring ( nextPage, MyLRParamNext ) ;

    web_url("ViewPage_2",
    "URL=https://www.XXX.{platform}/...page={MyLRParamNext}&amp;...actor=100",
    ...
    "Snapshot=t1138.inf",
    "Mode=HTML",
    LAST);

    shoudl work.. look up lr save string

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

    Re: correlate with local vars?

    [ QUOTE ]
    lr_save_sring ( nextPage, MyLRParamNext ) ;


    [/ QUOTE ]

    Well then this was the tip I needed; i.e. that I need to create a temp-like parm dynamically, which can then be used in the correlation. I was trying to use the loca/auto C variable directly in the correlation.

    -Thanks, Terry

  5. #5
    Moderator
    Join Date
    Aug 2001
    Location
    NC
    Posts
    6,041
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Total Downloaded
    0

    Re: correlate with local vars?

    <font class="small">Code:</font><hr /><pre>
    int pagecounter;

    ..

    for (
    pagecounter=1;
    pagecounter&lt; ( atoi( lr_eval_string ("{Correlated_Page_Limit}")));
    pagecounter++)
    {
    lr_save_int(pagecounter,"LR_Page_Num");

    ....

    web_url("ViewPage_2",
    "URL=https://www.XXX.{platform}/...page={LR_Page_Num}&amp;...actor=100",
    ...
    }
    </pre><hr />

    Or you might drop into a "do while" loop which continues until there is no more value to correlate for related to &lt;next page&gt;.
    James Pulley

    Replace ineffective offshore contracts, LoadRunnerByTheHour. Starting @ $19.95/hr USD.

    Put us to the test, skilled expertise is less expensive than you might imagine.

    Twitter: @LoadRunnerBTH @PerfBytes

  6. #6
    Advanced Member
    Join Date
    Jun 2006
    Location
    USA
    Posts
    785
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: correlate with local vars?

    JP got it better

    lr_save_int should work better than lr_save_string (Whcih would require an itoa operation before the step)

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

    Re: correlate with local vars?

    Thanks for everyone's suggestions. I tried them, and the settled on the following code, that did not require a temp parameter:

    <font class="small">Code:</font><hr /><pre>
    int i, iNextPage=0, iSnapshot=38, totalPages=atoi(lr_eval_string("{pageCount}"));
    char stepName[50]="\0", snapshotFile[50]="\0", sURL[1000]="\0";


    for (i=2; iNextPage!=totalPages; i++) {

    if (i&gt;3) {
    iNextPage=totalPages;
    } else {
    iNextPage=i;
    }
    sprintf(stepName, "ViewPage%d", iNextPage);
    sprintf(snapshotFile, "Snapshot=t11%d%s", iSnapshot++, ".inf");

    strcpy (sURL, lr_eval_string("URL=https://www.XXX.{platform}/business/...%2f{foldername}%2f{fullusername}%2f...3b1&amp;p age="));
    sprintf(sURL, "%s%d", sURL, iNextPage);
    strcat (sURL, lr_eval_string("&amp;connectionHandle={en_connecti onHandle}&amp;format=DHTML&amp;scalingfactor=100") );

    web_url(stepName,
    sURL,
    "TargetFrame=",
    "Resource=0",
    "RecContentType=text/html",
    "Referer=https://www.XXX.{platform}/.../{foldername}/{fullusername}/.../REPORT{reportName}.roi;1",
    snapshotFile,
    "Mode=HTML",
    LAST);

    }
    </pre><hr />

    The sprintf(sURL, "%s%d", sURL, iNextPage) was the key to avoiding the temp parameter. As with so many things C, this is but another way to skin the cat. Of course I did have to introduce the sURL string array, so I am not sure I gained much (other than some C refresher/learning...)

    -Terry

  8. #8
    Advanced Member
    Join Date
    Jun 2006
    Location
    USA
    Posts
    785
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: correlate with local vars?

    Terry,

    Show some heart to the guy who follows you in to fill in your position after you leave and who most likely will be asked to go thru the older scripts. Most likely the chap may be C-challenged (like yours truly and many others in the field).

    Your code while it works looks a bit complicated . I would try to make the code as simple as it can be made. (and thus more readable)

    PS: it really shouldnt matter as to what the stepname and the snapshot file name is going to be like - it doesnt matter in the final performance test results and not too important to the client either

  9. #9
    Advanced Member
    Join Date
    Jun 2006
    Location
    USA
    Posts
    785
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: correlate with local vars?

    in effect, your code can be rewritten as

    <font class="small">Code:</font><hr /><pre>
    sprintf(stepName, "ViewPage%d", iNextPage); sprintf(snapshotFile, "Snapshot=t11%d%s", iSnapshot++, ".inf");
    strcpy (sURL, lr_eval_string("URL=https://www.XXX.{platform}/business/...%2f{foldername}%2f{fullusername}%2f...3b1&amp;p age="));
    sprintf(sURL, "%s%d", sURL, iNextPage);
    strcat (sURL, lr_eval_string("&amp;connectionHandle={en_connecti onHandle}&amp;format=DHTML&amp;scalingfactor=100") );
    web_url(stepName, sURL, "TargetFrame=", "Resource=0", "RecContentType=text/html", "Referer=https://www.XXX.{platform}/.../{foldername}/{fullusername}/.../REPORT{reportName}.roi;1", snapshotFile, "Mode=HTML", LAST);</pre><hr />

    can be written as

    <font class="small">Code:</font><hr /><pre>
    lr_save_int (i, "LRNextPage");
    web_url(ViewPage_{LRNextPage}",
    "URL=https://www.XXX.{platform}/...page={LRNextPage}&amp;...actor=100",
    ...
    "Snapshot=t1138.inf",
    "Mode=HTML",
    LAST);
    </pre><hr />

    So you see, the four lines of c-code can be replaced with the one line in my example. Am I missing anything here?

    (I havent tried out whether ViewPage_{LRNextPage} works, but if it doesnt, it really doesnt matter).

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

    Re: correlate with local vars?

    [ QUOTE ]

    Show some heart to the guy who follows you...

    [/ QUOTE ]

    Oh, I don't want that. My code above of course is as plain as the nose on the end of face (which is always the case when <u>you</u> write the code). So I have taken your comment to heart and replaced the code creating the sURL array and replaced it with the single "lr_save_int(iNextPage,"nextPage")" line of code:
    <font class="small">Code:</font><hr /><pre>
    for (i=2; iNextPage!=totalPages;i++) {

    //lr_think_time(?);

    if (i &gt; iMin) {
    iNextPage=totalPages; // view last page (then exit this loop)
    } else {
    iNextPage=i; // view pages 2 and 3
    }
    lr_save_int(iNextPage,"nextPage");

    sprintf(stepName, "ViewPage%d", iNextPage);
    sprintf(snapshotFile, "Snapshot=t11%d%s", iSnapshot++, ".inf");

    </pre><hr />
    I did though keep the string arrays that define stepName and snapshotFile, as I just could not get myself to ignore the exact replication of what was captured during recording. Anyway now I simply use page={nextPage} in the URL= parm in the web_url() call.

    Thanks for all the feedback on this issue, but I now think this dog has been hung, huh?

    [img]/images/graemlins/smirk.gif[/img] Terry

    P.S. Someone previously in another thread pointed out that I should consider these script Actions as passing ships in the night, with a short shelf life. This is tough for me, having migrated from the QTP/Silk/functional testing world. I think this is yet another example of me forgetting this good suggestion...

 

 
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.40 (Pro) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 10.71%
vBulletin Optimisation provided by vB Optimise v2.7.1 (Pro) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.3.0 (Pro) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 01:33 PM.

Copyright BetaSoft Inc.