cancel
Showing results for 
Search instead for 
Did you mean: 

I need to grab some cookies for later use....

SOLVED
Highlighted
Contributor

Re: I need to grab some cookies for later use....

Hi richie, I think I understand now, you just need to loop over the list of cookies:

 

def cookieList = ["returnurl=9d97d277ed656a2", "authtype=72b76f4f5cf", "state=81ef1f0ff48fcd", "nonce=7511a89aaacda"] // You would use: testRunner.testCase.testSteps["GET Cookies"].testRequest.response.responseHeaders["Set-Cookie"]

for (cookie in cookieList) {
     def valueParts = cookie.split('=') // Split the value on the equals
     testRunner.testCase.setPropertyValue(valueParts[0], cookie)
}

 

And what that gets you is:

Capture.PNG 

Highlighted
Community Hero

Re: I need to grab some cookies for later use....

Hey @JustinM89 

 

Cheers for that - but am I missing something?  the cookie values are session variables and dynamic - so they change each time the test runs - so I can't specify them in an array list beforehand cos I dont know what they will be each time the test executes...??

 

nice one,

 

richie

if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
Highlighted
Contributor

Re: I need to grab some cookies for later use....

That was just for my testing -- you would just replace that with:

 

testRunner.testCase.testSteps["GET Cookies"].testRequest.response.responseHeaders["Set-Cookie"]

View solution in original post

Highlighted
Community Hero

Re: I need to grab some cookies for later use....

@richie,
Is it the same one as
https://community.smartbear.com/t5/SoapUI-Pro/Script-Assertion-To-Grab-4-Set-Cookies-To-Set-1-Cookie...

If yes, then this too solved, correct?



Regards,
Rao.
Highlighted
Community Hero

Re: I need to grab some cookies for later use....

Hey @nmrao,

Its related but not the same.
Anyway.. .fixed so im closing it off

Ta

Rich
if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors