lr脚本java协议调用post/get请求并验证响应信息

时间:2020-10-12 03:55:41
【文件属性】:
文件名称:lr脚本java协议调用post/get请求并验证响应信息
文件大小:4KB
文件格式:JAVA
更新时间:2020-10-12 03:55:41
lr脚本java 2、在LR中选择java协议的工程,然后再action部分调用如下; import postAndGet_result.java 事务开始 public static void main(String[] args) { //发送 GET 请求 String s=postAndGet_result.sendGet("http://localhost:xxxxxx", "key=123&v=456"); System.out.println(s); //发送 POST 请求 String sr=postAndGet_result.sendPost("http://localhost:xxxxxx", "{body内容}"); System.out.println(sr); } // 结果判断 如需要在响应返回的结果s中 检查有没有“”“200”这个值 boolean d = postAndGet_result.result(s,"200"); if(d){ 事务结束.pss }else{ 事务结束.fail }

网友评论