How to continue test steps after WS.verifyResponseStatusCode() returns false?

Hi All,
I am trying to use this WS.verifyResponseStatusCode(httpResponse, expectedCode) to verify the HTTP return code, and continue my test steps differently between 200 and 302 return codes. This method is expected to just return true or false, but I found that when the status code was not matching the expectedCode (i.e. the false scenario), this method just failed this test case without allowing to continue the test steps. Bellow is the console log.

2022-09-23 13:28:39.420 ERROR c.k.k.core.keyword.internal.KeywordMain - :x: Expected status code is ‘302’ but actual status code is ‘200’
2022-09-23 13:28:39.429 ERROR c.k.k.core.keyword.internal.KeywordMain - :x: Unable to verify response status code (Root cause: com.kms.katalon.core.exception.StepFailedException: Expected status code is ‘302’ but actual status code is ‘200’
at com.kms.katalon.core.keyword.internal.KeywordMain.stepFailed(KeywordMain.groovy:50)

I also tried with WS.verifyResponseStatusCode(historyResponse, expectedCode, FailureHandling.CONTINUE_ON_FAILURE), but it still failed this test case.

Thank you for your input.

The verify* keywords will do also an assertion under the hood.
If they return also a boolean or not … I am not sure, I never used them with such approach.
If your need is simply to create a decisional flow, better just send the request an get the status code from the response object, sort of:

def response = WS.sendRequest(findTestObject("your Test Object"))
status = response.getStatusCode()

if status blah blah blah ...
1 Like

Thank you bionel, I will try that.