SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 7 of 7
  1. #1
    Junior Member
    Join Date
    Jun 2003
    Location
    chennai
    Posts
    29
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Replacing variable with it\'s value

    Hi,

    I have following script where IP address http://172.30.6.12:6086 is repeated lot of times so whenever my box is changed i need to change this IP address from all places using Replace All.

    web_url("create-order.jsp",
    "URL=http://172.30.6.12:6086/gateway/pages/create/create-order.jsp",
    "Resource=0",
    "RecContentType=text/html",
    "Referer=http://172.30.6.12:6086/gateway/NFServlet?NFH_MessageId=&NFH_Page=%2Fpages%2Fsearc h%2Fsearch.jsp",
    "Snapshot=t3.inf",
    "Mode=HTTP",
    LAST);

    web_concurrent_start(NULL);
    web_url("gateway-create.css",
    "URL=http://172.30.6.12:6086/gateway/css/gateway-create.css",
    "Resource=1",
    "RecContentType=text/css",
    "Referer=http://172.30.6.12:6086/gateway/pages/create/create-order.jsp",
    LAST);

    So now to avoid this I tried this
    Char URL1[]=http://172.30.6.12:6086/gateway
    and I want to use this variable in web_url function like this
    web_url("gateway-create.css",
    "URL=="{URL1}/css/gateway-create.css"
    "Resource=1",
    but I think this will not work and LR will not expand it's variable value (just like SilkTest etc.) and for this purpose I have to use lr__eval_string function but how can i use that function in these calls I mean combination of web_url and other functions?
    I also tried different string variables and different functions like strcpy,strcat like this

    Char URL2[1024];
    strcpy(URL2,URL1)
    strcat(URL2,"/css/gateway-create.css")
    and before each call I can do this but I am searching for some other possible solution.

    Thanks for Help.

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

    Re: Replacing variable with it\'s value

    Consider the use of lr_save_string() for the macro'd on the fly replacement. In the case if your use of a C variable, well, you will really need to build the string with Sprintf and then replace the "URL=..." parameter....or any other as appropriate.
    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

  3. #3
    Moderator JakeBrake's Avatar
    Join Date
    Dec 2000
    Location
    St. Louis - Year 2025
    Posts
    15,609
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Replacing variable with it\'s value

    Please specify how you wish to substitute the url with another. There are a number of methods to make a substitution for a parameter, including passing it into the script as a starting argument, to using the built-in parameterization gadgetry. Contrary to what you believe, LR will expand it and expand it properly.

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

    Re: Replacing variable with it\'s value

    mishra, did you really intend to post this question at both QAForums and the LoadRunner yahoo groups. By posting in multiple locations with some common population you may be encouraging a non answer.

    Food for thought.
    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

  5. #5
    Member
    Join Date
    Sep 2003
    Location
    Cleveland, Oh
    Posts
    110
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Replacing variable with it\'s value

    You may want to give this a try. Put this in your vuser_init.

    #ifdef HTTPS
    char *http = "https://" ;
    #else
    char *http = "http://" ;
    #endif
    char* Url="172.30.6.12:6086";

    vuser_init()
    {
    lr_save_string(http,"http") ;
    lr_save_string(Url,"Url") ;
    return 0;
    }

    Then replace http://172.30.6.12:6086 with {http}{Url}
    1. 9.10
    2. HTTP
    3. HTML-Advanced
    4. Concurrent Groups
    5. LR91P026 QFE
    6. New
    7. All protocols - 3500 Vusers
    8. Yes
    9. Windows 2003 SP2
    10. No

  6. #6
    Member
    Join Date
    Dec 2003
    Posts
    205
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Replacing variable with it\'s value

    this is the way I currently have it setup...
    /*
    *Used for Recording against UrlA and playing back against UrlB. 1024+1 since default
    *VUGen web_set_max_html_param_len("1024");
    */
    char szBaseURL[1025] = {0};


    /*
    * After calling this function you can replace part of a dynamic URL with {baseURL} anywhere in your script.

    */


    void setBaseURLParameter(void) {

    const char *szURL = lr_get_attrib_string("URL");

    if(szURL)
    strncpy(szBaseURL, szURL ,1024);

    if(!szBaseURL[0])
    lr_output_message("Warning: No command line argument for URL. Should Look in controller Like: -URL http://www.mysite.com ");
    else
    lr_save_string(szBaseURL,"baseURL");


    //-----------------------------------------------------------------------//

    }

    vuser_init()
    {


    lr_save_string("http://www.mysite.com ","baseURL"); //

    //setBaseURLParameter();

    return 0;
    }

    Then in your script just replace the ip with baseURL.

    I have this code in my ...\Mercury LoadRunner\template\qtweb\init.c file so that is always there when needed.

    [ 05-11-2006, 04:14 PM: Message edited by: garifo ]

  7. #7
    Member
    Join Date
    Mar 2006
    Location
    Belgium
    Posts
    73
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Replacing variable with it\'s value

    I just do this with a parameter file

    everytime I need to access a different server I add a new line to the data file and then just point to the correct one for the test run

    Home
    http://123.233.234.90
    https://123.233.234.91

    for example

 

 

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 9.38%
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 04:18 PM.

Copyright BetaSoft Inc.