51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

查看: 2344|回复: 1
打印 上一主题 下一主题

[资料] 如何随机选取web_reg_save_param保存的函数

[复制链接]
  • TA的每日心情
    奋斗
    2019-3-7 09:49
  • 签到天数: 133 天

    连续签到: 1 天

    [LV.7]测试师长

    跳转到指定楼层
    1#
    发表于 2013-5-7 09:27:31 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
    本帖最后由 thirfing 于 2013-5-7 16:25 编辑

    Problem Description: How to randomly select parameters saved by web_reg_save_param

    How to randomly select parameters saved by web_reg_save_param with the attribute ORD = ALL.






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

    Solution: Use custom C coding to randomly select parameters

    You can randomly select parameters saved by web_reg_save_param with the attribute ORD = ALL by using custom C coding in your script.

    EXAMPLE:

    Action1()
    {


    char* temp,i;
    int j;

    //create a parameter with the desired boundaries
    web_reg_save_param ("pram", "NOTFOUND=ERROR", "LB=left_b","RB=right_b" , "ORD=ALL", LAST );

    //call to the URL
    web_url("HomePage", "URL=<Your_URL>", LAST);

    //get the total number of occurance captured
    j = atoi(lr_eval_string("{pram_count}"));

    //generate a random number between 1 to j
    sprintf(&i, "%d", ( 1 + rand() % j));

    //save the random number as a parameter - random_value
    lr_save_string(&i, "random_value");

    //get the value of parameter x (generated via random number )
    temp = lr_eval_string(lr_eval_string("{pram_{random_value}}"));

    //save the data as a parameter - random_param
    lr_save_string(temp, "random_param");

    //call a random URL
    web_url("Example", "URL={random_param}", LAST);

    return 0;
    }
    分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
    收藏收藏
    回复

    使用道具 举报

  • TA的每日心情
    奋斗
    2019-3-7 09:49
  • 签到天数: 133 天

    连续签到: 1 天

    [LV.7]测试师长

    2#
     楼主| 发表于 2013-5-8 09:51:12 | 只看该作者
    抢个沙发先
    回复 支持 反对

    使用道具 举报

    本版积分规则

    关闭

    站长推荐上一条 /1 下一条

    小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

    GMT+8, 2024-5-23 09:02 , Processed in 0.070450 second(s), 27 queries .

    Powered by Discuz! X3.2

    © 2001-2024 Comsenz Inc.

    快速回复 返回顶部 返回列表