博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
SoapUI中如何传递cookie
阅读量:6458 次
发布时间:2019-06-23

本文共 1768 字,大约阅读时间需要 5 分钟。

import com.eviware.soapui.support.types.StringToStringMap //Get all the cookies in the response def cookiesList = testRunner.testCase.getTestStepByName("Login").testRequest.response.responseHeaders["Set-Cookie"]def cookieNew= cookiesList.get(2).split(";")[0];log.info "cookie : "+cookieNew// Set the project level property : cookie , its value will be updated with cookieNewtestRunner.testCase.testSuite.project.setPropertyValue("cookie", cookieNew)cookieNew = '${#Project#cookie}'//Put cookie to a StringMapdef cookieMap = new StringToStringMap()cookieMap.put("Cookie",cookieNew)//Pass cookie to all testSteps of the projectdef testSuiteList =  testRunner.testCase.testSuite.project.getTestSuiteList()def testCaseListdef testStepListfor(testSuite in testSuiteList){    testCaseList =  testSuite.getTestCaseList()    for(testCase in testCaseList){        testStepList = testCase.getTestStepsOfType(com.eviware.soapui.impl.wsdl.teststeps.RestTestRequestStep.class)        for (testStep in testStepList){             testStep.testRequest.setRequestHeaders(cookieMap)        }    }}//Pass cookie to testStep "AA_BB" of testSuite "AA"def testSuiteList =  testRunner.testCase.testSuite.project.getTestSuiteList()def testCaseList def testStepList for(testSuite in testSuiteList){    if(testSuite.name == "AA"){        testCaseList = testSuite.getTestCaseList()        for(testCase in testCaseList){            testStepList = testCase.getTestStepsOfType(com.eviware.soapui.impl.wsdl.teststeps.RestTestRequestStep.class)            for(testStep in testStepList){                if(testStep.name == "AA_BB"){                   testStep.testRequest.setRequestHeaders(cookieMap)                }            }        }    }}

 

转载于:https://www.cnblogs.com/testing-life/p/4913754.html

你可能感兴趣的文章
python爬虫学习研究
查看>>
如何设置tomcat定时自动重启
查看>>
webpack手动搭建vue环境时,main.js引入一直报Uncaught SyntaxError: Unexpected identifier
查看>>
[2019.2.28]BZOJ4033 [HAOI2015]树上染色
查看>>
idea 版本控制 忽略要提交的文件
查看>>
java伪代码 读后感
查看>>
Linux用户基础
查看>>
HDU 1285 确定比赛名次【拓扑排序】
查看>>
mycelipse中关于编码的配置
查看>>
PyQt5应用与实践
查看>>
Linux 删除用户时报错:userdel: user zhoulijiang is currently used by process 1
查看>>
Linux网络配置之虚拟网卡的配置(Red Hat 6.5)
查看>>
使用Photoshop+960 Grid System模板进行网页设计
查看>>
基于alpine用dockerfile创建的ssh镜像
查看>>
样式表
查看>>
[MapReduce_8] MapReduce 中的自定义分区实现
查看>>
C# Task用法
查看>>
2018年个人的一些简单预测
查看>>
基于bing 搜索引擎和 Microsoft Academic Search 的高校申请指南的NABC分析
查看>>
iOS 疑难杂症 — — 推送本地国际化 loc-key 本地化失败的问题
查看>>