Forum Discussion
awsgamdocs
11 years agoOccasional Contributor
akeo wrote: 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.
Hi,
I need to get the token from Login REST then to add it as a header with name: "authorization" and value: "the actual token we get"
By using what you suggested I was able to see the token:-
def setCookie = context.testCase.testSteps["/smb/Login - Request"].testRequest.response.responseHeaders["uxfauthorization"]
My question is how can I transfer it to the next REST's request as header?
I appreciate the help.
BTW, you can see my full POST here:-
viewtopic.php?f=2&t=23132
Related Content
- 10 years ago
Recent Discussions
- 16 hours ago