1、环境准备:

     友情提示:用本地环境,不要用虚拟机

     LoadRunner11----->对应JDK1.6版本(32位)

LoadRunner12----->对应JDK1.7版本(32位)

  (一)、JDK下载安装完成后,配置环境变量:

1)、系统变量→新建 JAVA_HOME 变量 ,变量值填写jdk的安装目录(例如:C:\Java\jdk1.7.0_25)

2)、系统变量→寻找 Path 变量→编辑,在变量值最后输入 %JAVA_HOME%\bin;%JAVA_HOME%\jre\bin;

3)、系统变量→新建 CLASSPATH 变量,变量值填写   .;%JAVA_HOME%\lib;%JAVA_HOME%\lib\tools.jar(注意最前面有一点)

系统变量配置完毕,检验是否配置成功 运行cmd 输入 java -version

若如图所示 显示版本信息 则说明安装和配置成功。

2.在Idea中编写好对应的接口脚本

将脚本构建成jar包,如下图所示:

3.在loadrunner中创建JavaVuser协议脚本:

1)、将调试好的java代码拷贝到loadrunner中:

import lrapi.lr;
//将包文件引入
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject; import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils; import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.util.List;
import java.util.Map; //引入MD5文件
import testmd5.MD5;
//引入HttpClientRequest文件
import testmd5.HttpClientRequest;
public class Actions
{ public int init() throws Throwable {
return 0;
}//end of init public int action() throws Throwable {
// 定义登录URL地址
String login_url = "http://******/mobile/api/user/login";
// 定义请求的参数
String login_data = "{\"mobile\":\"130********\",\"password\":\"123456\"}";
// 调用HttpClientRequest类里面的sendpost方法
//添加事物函数
lr.start_transaction("登录");
String PostResult = HttpClientRequest.sendPost(login_url, login_data);
System.out.println("登录返回:"+ PostResult);
JSONObject jsonobj = new JSONObject(PostResult);
int status = (int) jsonobj.get("code");
//根据status返回值,判断登录事物是否成功
if(status == 0)
{
lr.end_transaction("登录", lr.PASS);
}
else
{
lr.end_transaction("登录", lr.FAIL);
}
System.out.println("code:" +status);
//获取token值
String token = (String) jsonobj.getJSONObject("data").get("token");
System.out.println("token:" +token); String modifypaypwd_url = "http://*********/mobile/api/user/resetpaypwd";
//调用md5类里面的getmd5code这个方法
String newPasswod = MD5.GetMD5Code("123456");
System.out.println("newPasswod:" +newPasswod);
String modifypaypwd_data = "{\"token\":\""+token+"\",\"password\":\""+newPasswod+"\"}";
String PostMd5Result = HttpClientRequest.sendPost(modifypaypwd_url, modifypaypwd_data);
System.out.println("PostMd5Result:" + PostMd5Result);
return 0;
}//end of action public int end() throws Throwable {
return 0;
}//end of end
}

2)、设置RunTime Settings:

1、将lib文件下的包导入

2、将jdk目录lib下的dt.jar、tools.jar导入

3、将构建完成的jar包导入

最终导入的文件如下:

3)、运行效果如下:

Virtual User Script started at : 2019/4/17 16:54:22
Starting action vuser_init.
Ending action vuser_init.
Running Vuser...
Starting iteration 1.
Maximum number of concurrent connections per server: 4 [MsgId: MMSG-26989]
Starting action Actions.
System.out: 登录返回:{"code":0,"msg":"成功调用","data":{"id":704,"username":"test8722","sex":1,"age":20,"mobile":"13801008352","email":"7079@test.com","gqid":"4000001","money":0.0,"pmoney":9517.0,"createtime":1555075335000,"lasttime":1555491263711,"token":"VYreWM0+MHf4smCRjCmWvGLPK9634RXHxdVDPYE10qc7lT4VA/LE4SURxJfUn4eYxRU/jxaEwo/fQbjJJq9BrA==","identity":"9c2de77d354cf806"}} Notify:
System.out: code:0 Notify:
System.out: token:VYreWM0+MHf4smCRjCmWvGLPK9634RXHxdVDPYE10qc7lT4VA/LE4SURxJfUn4eYxRU/jxaEwo/fQbjJJq9BrA== Notify:
System.out: null--->[HTTP/1.1 200 OK] Notify:
System.out: Date--->[Wed, 17 Apr 2019 08:54:23 GMT] Notify:
System.out: Transfer-Encoding--->[chunked] Notify:
System.out: Content-Type--->[application/json;charset=UTF-8] Notify:
System.out: Server--->[Apache-Coyote/1.1] Notify:
System.out: GetResult:{"code":0,"msg":"成功调用","data":{"lists":[{"id":1176,"orderNum":"2019041222333200001","payType":2,"createTime":1555079612000,"orderReceivetTimeMin":1442597104000,"orderReceiveTimeMax":1442598904000,"receiveCar":{"id":23,"carNum":"粤C-6165","carColor":2},"remark":"老板,我要退货","receiveWindow":-1,"receiveTime":1442597104000,"status":0,"receiveAddr":{"id":1,"addrId":1,"addrDesc":"中石化博爱七路"},"historyGoodsSet":[{"id":2142,"goodsName":"清远走地鸡","spec":"","price":60.0,"description":"清远走地鸡 每只60","goodsImgSet":[{"id":4489,"imgName":"20150919142017.jpg","imgUrl":"/upload/20150919142017.jpg","createTime":1442647654000}],"canOrderMin":1420041600000,"canOrderMax":1420127999000,"canReceiveMin":1420041600000,"canReceiveMax":1420127999000,"receiveIntervalMin":0,"isNextDay":0,"status":0,"createTime":1442647654000,"publishTime":1442643662000,"buyCount":1},{"id":2141,"goodsName":"咀香园蛋卷","spec":"","price":9.0,"description":"中山特产咀香园160g蛋卷 下午茶休闲零食小吃 香葱蛋卷","goodsImgSet":[{"id":4488,"imgName":"20150919143506.jpg","imgUrl":"/upload/20150919143506.jpg","createTime":1442644739000}],"canOrderMin":1420041600000,"canOrderMax":1420127999000,"canReceiveMin":1420041600000,"canReceiveMax":1420127999000,"receiveIntervalMin":0,"isNextDay":0,"status":0,"createTime":1442644739000,"publishTime":1442644524000,"buyCount":1}],"pay":{"id":1118,"payId":"122019041222333200001","payType":2,"payPrice":69.0,"count":2,"refId":"","state":1,"payTime":1555079613000},"price":69.0,"count":2},{"id":1175,"orderNum":"2019041222282200001","payType":2,"createTime":1555079302000,"orderReceivetTimeMin":1442597104000,"orderReceiveTimeMax":1442598904000,"receiveCar":{"id":23,"carNum":"粤C-6165","carColor":2},"remark":"老板,我要退货","receiveWindow":-1,"receiveTime":1442597104000,"status":0,"receiveAddr":{"id":1,"addrId":1,"addrDesc":"中石化博爱七路"},"historyGoodsSet":[{"id":2140,"goodsName":"咀香园蛋卷","spec":"","price":9.0,"description":"中山特产咀香园160g蛋卷 下午茶休闲零食小吃 香葱蛋卷","goodsImgSet":[{"id":4487,"imgName":"20150919143506.jpg","imgUrl":"/upload/20150919143506.jpg","createTime":1442644739000}],"canOrderMin":1420041600000,"canOrderMax":1420127999000,"canReceiveMin":1420041600000,"canReceiveMax":1420127999000,"receiveIntervalMin":0,"isNextDay":0,"status":0,"createTime":1442644739000,"publishTime":1442644524000,"buyCount":1},{"id":2139,"goodsName":"清远走地鸡","spec":"","price":60.0,"description":"清远走地鸡 每只60","goodsImgSet":[{"id":4486,"imgName":"20150919142017.jpg","imgUrl":"/upload/20150919142017.jpg","createTime":1442647654000}],"canOrderMin":1420041600000,"canOrderMax":1420127999000,"canReceiveMin":1420041600000,"canReceiveMax":1420127999000,"receiveIntervalMin":0,"isNextDay":0,"status":0,"createTime":1442647654000,"publishTime":1442643662000,"buyCount":1}],"pay":{"id":1117,"payId":"122019041222282200001","payType":2,"payPrice":69.0,"count":2,"refId":"","state":1,"payTime":1555079302000},"price":69.0,"count":2},{"id":1174,"orderNum":"2019041222265700001","payType":2,"createTime":1555079217000,"orderReceivetTimeMin":1442597104000,"orderReceiveTimeMax":1442598904000,"receiveCar":{"id":23,"carNum":"粤C-6165","carColor":2},"remark":"老板,我要退货","receiveWindow":-1,"receiveTime":1442597104000,"status":0,"receiveAddr":{"id":1,"addrId":1,"addrDesc":"中石化博爱七路"},"historyGoodsSet":[{"id":2138,"goodsName":"咀香园蛋卷","spec":"","price":9.0,"description":"中山特产咀香园160g蛋卷 下午茶休闲零食小吃 香葱蛋卷","goodsImgSet":[{"id":4485,"imgName":"20150919143506.jpg","imgUrl":"/upload/20150919143506.jpg","createTime":1442644739000}],"canOrderMin":1420041600000,"canOrderMax":1420127999000,"canReceiveMin":1420041600000,"canReceiveMax":1420127999000,"receiveIntervalMin":0,"isNextDay":0,"status":0,"createTime":1442644739000,"publishTime":1442644524000,"buyCount":1},{"id":2137,"goodsName":"清远走地鸡","spec":"","price":60.0,"description":"清远走地鸡 每只60","goodsImgSet":[{"id":4484,"imgName":"20150919142017.jpg","imgUrl":"/upload/20150919142017.jpg","createTime":1442647654000}],"canOrderMin":1420041600000,"canOrderMax":1420127999000,"canReceiveMin":1420041600000,"canReceiveMax":1420127999000,"receiveIntervalMin":0,"isNextDay":0,"status":0,"createTime":1442647654000,"publishTime":1442643662000,"buyCount":1}],"pay":{"id":1116,"payId":"122019041222265700001","payType":2,"payPrice":69.0,"count":2,"refId":"","state":1,"payTime":1555079217000},"price":69.0,"count":2},{"id":1173,"orderNum":"2019041222260100001","payType":2,"createTime":1555079161000,"orderReceivetTimeMin":1442597104000,"orderReceiveTimeMax":1442598904000,"receiveCar":{"id":23,"carNum":"粤C-6165","carColor":2},"remark":"老板,我要退货","receiveWindow":-1,"receiveTime":1442597104000,"status":0,"receiveAddr":{"id":1,"addrId":1,"addrDesc":"中石化博爱七路"},"historyGoodsSet":[{"id":2136,"goodsName":"咀香园蛋卷","spec":"","price":9.0,"description":"中山特产咀香园160g蛋卷 下午茶休闲零食小吃 香葱蛋卷","goodsImgSet":[{"id":4483,"imgName":"20150919143506.jpg","imgUrl":"/upload/20150919143506.jpg","createTime":1442644739000}],"canOrderMin":1420041600000,"canOrderMax":1420127999000,"canReceiveMin":1420041600000,"canReceiveMax":1420127999000,"receiveIntervalMin":0,"isNextDay":0,"status":0,"createTime":1442644739000,"publishTime":1442644524000,"buyCount":1},{"id":2135,"goodsName":"清远走地鸡","spec":"","price":60.0,"description":"清远走地鸡 每只60","goodsImgSet":[{"id":4482,"imgName":"20150919142017.jpg","imgUrl":"/upload/20150919142017.jpg","createTime":1442647654000}],"canOrderMin":1420041600000,"canOrderMax":1420127999000,"canReceiveMin":1420041600000,"canReceiveMax":1420127999000,"receiveIntervalMin":0,"isNextDay":0,"status":0,"createTime":1442647654000,"publishTime":1442643662000,"buyCount":1}],"pay":{"id":1115,"payId":"122019041222260100001","payType":2,"payPrice":69.0,"count":2,"refId":"","state":1,"payTime":1555079161000},"price":69.0,"count":2},{"id":1171,"orderNum":"2019041222251500001","payType":2,"createTime":1555079115000,"orderReceivetTimeMin":1442597104000,"orderReceiveTimeMax":1442598904000,"receiveCar":{"id":23,"carNum":"粤C-6165","carColor":2},"remark":"老板,我要退货","receiveWindow":-1,"receiveTime":1442597104000,"status":0,"receiveAddr":{"id":1,"addrId":1,"addrDesc":"中石化博爱七路"},"historyGoodsSet":[{"id":2132,"goodsName":"清远走地鸡","spec":"","price":60.0,"description":"清远走地鸡 每只60","goodsImgSet":[{"id":4479,"imgName":"20150919142017.jpg","imgUrl":"/upload/20150919142017.jpg","createTime":1442647654000}],"canOrderMin":1420041600000,"canOrderMax":1420127999000,"canReceiveMin":1420041600000,"canReceiveMax":1420127999000,"receiveIntervalMin":0,"isNextDay":0,"status":0,"createTime":1442647654000,"publishTime":1442643662000,"buyCount":1},{"id":2131,"goodsName":"咀香园蛋卷","spec":"","price":9.0,"description":"中山特产咀香园160g蛋卷 下午茶休闲零食小吃 香葱蛋卷","goodsImgSet":[{"id":4478,"imgName":"20150919143506.jpg","imgUrl":"/upload/20150919143506.jpg","createTime":1442644739000}],"canOrderMin":1420041600000,"canOrderMax":1420127999000,"canReceiveMin":1420041600000,"canReceiveMax":1420127999000,"receiveIntervalMin":0,"isNextDay":0,"status":0,"createTime":1442644739000,"publishTime":1442644524000,"buyCount":1}],"pay":{"id":1113,"payId":"122019041222251500001","payType":2,"payPrice":69.0,"count":2,"refId":"","state":1,"payTime":1555079115000},"price":69.0,"count":2},{"id":1170,"orderNum":"2019041222203800001","payType":2,"createTime":1555078838000,"orderReceivetTimeMin":1442597104000,"orderReceiveTimeMax":1442598904000,"receiveCar":{"id":23,"carNum":"粤C-6165","carColor":2},"remark":"老板,我要退货","receiveWindow":-1,"receiveTime":1442597104000,"status":0,"receiveAddr":{"id":1,"addrId":1,"addrDesc":"中石化博爱七路"},"historyGoodsSet":[{"id":2130,"goodsName":"清远走地鸡","spec":"","price":60.0,"description":"清远走地鸡 每只60","goodsImgSet":[{"id":4477,"imgName":"20150919142017.jpg","imgUrl":"/upload/20150919142017.jpg","createTime":1442647654000}],"canOrderMin":1420041600000,"canOrderMax":1420127999000,"canReceiveMin":1420041600000,"canReceiveMax":1420127999000,"receiveIntervalMin":0,"isNextDay":0,"status":0,"createTime":1442647654000,"publishTime":1442643662000,"buyCount":1},{"id":2129,"goodsName":"咀香园蛋卷","spec":"","price":9.0,"description":"中山特产咀香园160g蛋卷 下午茶休闲零食小吃 香葱蛋卷","goodsImgSet":[{"id":4476,"imgName":"20150919143506.jpg","imgUrl":"/upload/20150919143506.jpg","createTime":1442644739000}],"canOrderMin":1420041600000,"canOrderMax":1420127999000,"canReceiveMin":1420041600000,"canReceiveMax":1420127999000,"receiveIntervalMin":0,"isNextDay":0,"status":0,"createTime":1442644739000,"publishTime":1442644524000,"buyCount":1}],"pay":{"id":1112,"payId":"122019041222203800001","payType":2,"payPrice":69.0,"count":2,"refId":"","state":1,"payTime":1555078839000},"price":69.0,"count":2},{"id":1169,"orderNum":"2019041222130900001","payType":2,"createTime":1555078389000,"orderReceivetTimeMin":1442597104000,"orderReceiveTimeMax":1442598904000,"receiveCar":{"id":23,"carNum":"粤C-6165","carColor":2},"remark":"testtest","receiveWindow":-1,"receiveTime":1442597104000,"status":0,"receiveAddr":{"id":1,"addrId":1,"addrDesc":"中石化博爱七路"},"historyGoodsSet":[{"id":2128,"goodsName":"清远走地鸡","spec":"","price":60.0,"description":"清远走地鸡 每只60","goodsImgSet":[{"id":4475,"imgName":"20150919142017.jpg","imgUrl":"/upload/20150919142017.jpg","createTime":1442647654000}],"canOrderMin":1420041600000,"canOrderMax":1420127999000,"canReceiveMin":1420041600000,"canReceiveMax":1420127999000,"receiveIntervalMin":0,"isNextDay":0,"status":0,"createTime":1442647654000,"publishTime":1442643662000,"buyCount":1},{"id":2127,"goodsName":"咀香园蛋卷","spec":"","price":9.0,"description":"中山特产咀香园160g蛋卷 下午茶休闲零食小吃 香葱蛋卷","goodsImgSet":[{"id":4474,"imgName":"20150919143506.jpg","imgUrl":"/upload/20150919143506.jpg","createTime":1442644739000}],"canOrderMin":1420041600000,"canOrderMax":1420127999000,"canReceiveMin":1420041600000,"canReceiveMax":1420127999000,"receiveIntervalMin":0,"isNextDay":0,"status":0,"createTime":1442644739000,"publishTime":1442644524000,"buyCount":1}],"pay":{"id":1111,"payId":"122019041222130900001","payType":2,"payPrice":69.0,"count":2,"refId":"","state":1,"payTime":1555078390000},"price":69.0,"count":2}]}} Notify:
System.out: orderListCode:0 Notify:
Ending action Actions.
Ending iteration 1.
Ending Vuser...
Starting action vuser_end.
Ending action vuser_end.
Vuser Terminated.

  

loadrunner12中JavaVuser脚本的编写的更多相关文章

  1. 性能测试学习 第七课 --loadrunner中JavaVuser脚本的编写

    1.环境准备:      LoadRunner11----->对应JDK1.6版本(32位) LoadRunner12----->对应JDK1.7版本(32位) (一).JDK下载安装完成 ...

  2. loadrunner中JavaVuser脚本的编写

    1.环境准备:      LoadRunner11----->对应JDK1.6版本(32位) LoadRunner12----->对应JDK1.7版本(32位) (一).JDK下载安装完成 ...

  3. SecureCRT中python脚本编写

    SecureCRT中python脚本编写学习指南 SecureCRT python 引言 在测试网络设备中,通常使用脚本对设备端进行配置和测试以及维护:对于PE设备的测试维护人员来说使用较多是Secu ...

  4. Loadrunner中web脚本转成JavaVuser脚本

    先用web方式录制好脚本,进行参数化,关联验证等操作,之后执行以下步骤: 1)将要转换的web脚本复制出来并保存到web.txt中2)参数界定符部分需要由{}手动修改成<>,包括参数化的和 ...

  5. Tsung脚本中使用动态参数(一)---直接在脚本里编写Erlang代码

    杀死一个程序猿,只要改三次需求.同理,杀死一个接口自动化测试人员,只要改三次接口数据处理方式.我目前的状态,改了一次接口数据处理方式,有一种胸闷的感觉. 因为改需求,所以,要改脚本.T_T.所以,才有 ...

  6. centos shell编程6一些工作中实践脚本 nagios监控脚本 自定义zabbix脚本 mysql备份脚本 zabbix错误日志 直接送给bc做计算 gzip innobackupex/Xtrabackup 第四十节课

    centos   shell编程6一些工作中实践脚本   nagios监控脚本 自定义zabbix脚本 mysql备份脚本 zabbix错误日志  直接送给bc做计算  gzip  innobacku ...

  7. [改善Java代码]易变业务使用脚本语言编写

    建议16: 易变业务使用脚本语言编写 Java世界一直在遭受着异种语言的入侵,比如PHP.Ruby.Groovy.JavaScript等,这些“入侵者”都有一个共同特征:全是同一类语言—脚本语言,它们 ...

  8. 通过Arcpy在ArcMap工具箱中添加脚本计算面图层的起终点坐标

    关键词: Arcpy,ArcMap Toolbox, Coordinates of Polygon 需求分析: Arcmap中添加有三个图层:图层“GY乡级河道”(面图层)是全县13个乡镇全部的乡级河 ...

  9. VSCode调试Html中的脚本 vscode前端常用插件推荐,搭建JQuery、Vue等开发环境 vsCode 添加浏览器调试和js调试的方法总结 VS Code - Debugger for Chrome调试js

    一.背景 使用Visual Studio Code写了一个简单的Html页面,想调试下其中script标签里的javascript代码,网上查了一通,基本都是复制粘贴或者大同小异的文章,就是要安装De ...

随机推荐

  1. Do-Now—团队Scrum 冲刺博客五

    各个成员今日完成的任务 侯泽洋: 每日任务页面编写,任务修改功能 周亚杰:完成个人中心页面设计 王志伟:完成个人中心页面设计 唐才铭:启动动画及引导页与项目合并 项目燃尽图 站立式会议照片 各个成员遇 ...

  2. java判断通常的逻辑

    package com.stylefeng.guns.core.common.constant.factory; import com.baomidou.mybatisplus.mapper.Enti ...

  3. Java课程寒假之开发记账本软件(Android版)之一

    一.选择编译软件 最终选择了目前较为流行的Android Studio,网上的评价都比较偏向于好评. 安装的过程还算比较正常,没有什么太大的波折,解压安装虽然直接,但对于我这种每次装编译软件都有形形色 ...

  4. [Codeforces Round #508 (Div. 2)][Codeforces 1038E. Maximum Matching]

    前几天给舍友讲这题的时候感觉挺有意思的,就贴上来吧... 题目链接:1038E - Maximum Matching 题目大意:有\(n\)个棒子,每个条两端有颜色\(c1,c2\)以及他的价值\(v ...

  5. Linux各目录及每个目录的详细介绍(转载)

    [常见目录说明] 目录 /bin 存放二进制可执行文件(ls,cat,mkdir等),常用命令一般都在这里. /etc 存放系统管理和配置文件 /home 存放所有用户文件的根目录,是用户主目录的基点 ...

  6. 2019.4.10 初识puppeteer

    注:原地址:https://www.cnblogs.com/paris-test/p/9705075.html 一.Puppeteer 介绍 Puppeteer 翻译是操纵木偶的人,利用这个工具,我们 ...

  7. Codeforces 785 - A/B/C/D/E - (Undone)

    链接:https://codeforces.com/contest/785 A - Anton and Polyhedrons #include<bits/stdc++.h> using ...

  8. Django中web开发用md5加密图片名并存储静态文件夹

    一般在开发中,有的网站存在大量图片,首先图片的名称是不能重复的, 但是除了数据库可用的id以外我们可以用time模块中time.time()获取的时间来进行md5加密操作, 因为time模块所产生的时 ...

  9. sqlserver 表循环-游标、表变量、临时表

    SQL Server遍历表的几种方法 阅读目录 使用游标 使用表变量 使用临时表 在数据库开发过程中,我们经常会碰到要遍历数据表的情形,一提到遍历表,我们第一印象可能就想到使用游标,使用游标虽然直观易 ...

  10. VueJS教程

    文档资料参考: 参考:https://cn.vuejs.org/ 参考:Vue-Cli(客户端) 参考:创建一个Vue项目 参考:https://codesandbox.io 参考:https://c ...