• LoadRunner生成随机位数的字符串


    1、新建生成随机数函数文件randString.h

    //生成随机字符串
    char *randString(slen)
    {
        int i,randid;
        char temp[100]="";
        char character_set[52] = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
    
        for(i=1;i<slen;i++){
            randid = rand()%52;
            sprintf(temp,"%s%c",temp,character_set[randid]);
        }
    
        return(temp);
    }

    2、在loadrunner新建脚本,导入随机数函数头文件randString.h

    右键新脚本空白区域,选择add files to script,添加头文件:

    3、编辑globals.h文件

    添加脚本:#include "randString.h"

    4、编写action脚本,调用生成随机位数字符串函数

    Action(){
    
    char a[100]="";
    strcpy(a,lr_eval_string(randString(32)));
    lr_output_message("%s",a);
    return 0;
    
    }

    5、执行结果

    生成32位随机字符串

  • 相关阅读:
    简单理解OOP——面向对象编程
    SpringMVC拦截器
    Vue简洁及基本用法
    springMVC实现文件上传下载
    Python笔记⑤爬虫
    Python笔记4
    Python笔记3
    Python基础语法笔记2
    Python基础入门语法1
    Navicat连接mysql时候出现1251错误代码
  • 原文地址:https://www.cnblogs.com/wzl0916/p/13589896.html
Copyright © 2020-2023  润新知