heathen462
12 years agoNew Contributor
responseHeaders not available in LoadTest?
I've searched all over, and please forgive me if the answer is already out there, but I cannot find the solution to this issue.
I have a RESTful API that uses cookie authentication. Using the normal TestCase runner, I have a groovy transfer script that retrieves the "Set-Cookie" param from the authentication login request response headers, and applies this cookie to the rest of the requests in the test case.
When I attempt to run a load test, the transfer step ALWAYS fails, stating that responseHeaders does not exist. I'm at a complete loss, and have tried everything from keeping the http session alive to passing the username/password. Nothing works.
How do I retrieve/manipulate the response headers in a load test?
This is the transfer step:
it is failing to on
as testRunner.testCase.testSteps["authentication-login"].testRequest.response.responseHeaders doesn't exist in LoatTest, apparently.
Any assistance or just a "n00b, the answer is here" is greatly appreciated. I've already spent hours on this and am at my whit's end.
I have a RESTful API that uses cookie authentication. Using the normal TestCase runner, I have a groovy transfer script that retrieves the "Set-Cookie" param from the authentication login request response headers, and applies this cookie to the rest of the requests in the test case.
When I attempt to run a load test, the transfer step ALWAYS fails, stating that responseHeaders does not exist. I'm at a complete loss, and have tried everything from keeping the http session alive to passing the username/password. Nothing works.
How do I retrieve/manipulate the response headers in a load test?
This is the transfer step:
// You can get http header of "Set-Cookie" from "login" test step in soapUI
def setCookie = testRunner.testCase.testSteps["authentication-login"].testRequest.response.responseHeaders["Set-Cookie"]
// if you want to get PHPSESSID=value, use this regular expression
def re = /(PHPSESSID=[A-Za-z0-9]+)/
def matcher = ( setCookie =~ re )
def cookie = matcher[0][0]
// Iterate through all test steps and add the session cookie to the headers.
for ( tstep in testRunner.testCase.testSteps ) {
testStepName = ( tstep.key )
//assuming your login request is entitled "login" and your transfer groovy step is entitled "TransferAuthCookie"
if ( testStepName != 'authentication-login' && testStepName != 'TransferAuthCookie') {
testRunner.testCase.testSteps[testStepName].testRequest.requestHeaders["Cookie"] = cookie
}
}
it is failing to on
def setCookie = testRunner.testCase.testSteps["authentication-login"].testRequest.response.responseHeaders["Set-Cookie"]
as testRunner.testCase.testSteps["authentication-login"].testRequest.response.responseHeaders doesn't exist in LoatTest, apparently.
Any assistance or just a "n00b, the answer is here" is greatly appreciated. I've already spent hours on this and am at my whit's end.