Forum Discussion
14 years ago
Please see this Groovy script.
---
// You can get http header of "Set-Cookie" from "login someone" test step in soapUI
def setCookie = testRunner.testCase.testSteps["login someone"].testRequest.response.responseHeaders["Set-Cookie"]
// if you want to get JSESSIONID=value, use this regular expression
re = /(JSESSIONID=[A-Za-z0-9]+)/
matcher = ( setCookie =~ re )
def jsesid = matcher[0][0]
// confirm the JSESSIONID with log.info
log.info "$jsesid"
// Set the ID to TestCase cookie property
def tc = testRunner.testCase.testSuite.getTestCaseByName("sample testcase")
tc.setPropertyValue("cookie","$jsesid")
---
TestCase property is able to use a http cookie header's value.
Enter "${#TestCase#cookie}" to "Value" and "Cookie" to "Header" in a Test Step's "Header" part.
Please try it. Thank you.
---
// You can get http header of "Set-Cookie" from "login someone" test step in soapUI
def setCookie = testRunner.testCase.testSteps["login someone"].testRequest.response.responseHeaders["Set-Cookie"]
// if you want to get JSESSIONID=value, use this regular expression
re = /(JSESSIONID=[A-Za-z0-9]+)/
matcher = ( setCookie =~ re )
def jsesid = matcher[0][0]
// confirm the JSESSIONID with log.info
log.info "$jsesid"
// Set the ID to TestCase cookie property
def tc = testRunner.testCase.testSuite.getTestCaseByName("sample testcase")
tc.setPropertyValue("cookie","$jsesid")
---
TestCase property is able to use a http cookie header's value.
Enter "${#TestCase#cookie}" to "Value" and "Cookie" to "Header" in a Test Step's "Header" part.
Please try it. Thank you.
Related Content
- 10 years ago
- 6 years ago
Recent Discussions
- 16 hours ago