SoapUI 5.2.0如何设置header属性
SoapUI 5.2.0 how to set header property
我有一个测试用例,在第一个 testStep 中我提出了一个请求。我在第一个请求的响应中检索了 JSESSIONID,现在我想将它作为 "cookie" 属性 放在我所有其他 testStep 请求的 header 中。我该怎么做?
log.info "$jsessionid"
for (testStep in testRunner.testCase.getTestStepList()){
if (testStep.getName() != "Request 1" && testStep.getName() != "Groovy Script") {
//set the JSESSIONID in the request header property "Cookie"
}
}
我的其他人的 testStep 在他们的 header
中有一些值
- 连接:keep-alive
- Proxy-Connection : keep-alive
- Accept-Encoding : UTF8
- 接受:application/json
- 等等
我想在列表中添加 "cookie : JSESSIONID=MYVALUE",或者如果 属性 已经存在则替换它。
我找到了一种在每个其他 testStep 的 header 中设置 "Cookie" 属性 的方法。 属性 添加到列表中,这样它将替换旧的 cookie 值。
import com.eviware.soapui.impl.wsdl.teststeps.*
//(...)
//Retrieve the JSESSIONID and put it in a variable
log.info "$jsessionid"
for (testStep in testRunner.testCase.getTestStepList()){
if (testStep instanceof RestTestRequestStep && testStep.getName() != "Request 1" && testStep.getName() != "Groovy Script") {
def list = []
list.add(jsessionid)
def headers = testStep.testRequest.requestHeaders
headers["Cookie"] = list
testStep.testRequest.requestHeaders = headers
log.info testStep.testRequest.requestHeaders["Cookie"]
}
}
我有一个测试用例,在第一个 testStep 中我提出了一个请求。我在第一个请求的响应中检索了 JSESSIONID,现在我想将它作为 "cookie" 属性 放在我所有其他 testStep 请求的 header 中。我该怎么做?
log.info "$jsessionid"
for (testStep in testRunner.testCase.getTestStepList()){
if (testStep.getName() != "Request 1" && testStep.getName() != "Groovy Script") {
//set the JSESSIONID in the request header property "Cookie"
}
}
我的其他人的 testStep 在他们的 header
中有一些值- 连接:keep-alive
- Proxy-Connection : keep-alive
- Accept-Encoding : UTF8
- 接受:application/json
- 等等
我想在列表中添加 "cookie : JSESSIONID=MYVALUE",或者如果 属性 已经存在则替换它。
我找到了一种在每个其他 testStep 的 header 中设置 "Cookie" 属性 的方法。 属性 添加到列表中,这样它将替换旧的 cookie 值。
import com.eviware.soapui.impl.wsdl.teststeps.*
//(...)
//Retrieve the JSESSIONID and put it in a variable
log.info "$jsessionid"
for (testStep in testRunner.testCase.getTestStepList()){
if (testStep instanceof RestTestRequestStep && testStep.getName() != "Request 1" && testStep.getName() != "Groovy Script") {
def list = []
list.add(jsessionid)
def headers = testStep.testRequest.requestHeaders
headers["Cookie"] = list
testStep.testRequest.requestHeaders = headers
log.info testStep.testRequest.requestHeaders["Cookie"]
}
}