Wait for Response - how to get status_code

I need check in application if request was sent after user login. In order to do that, I wanted to use Wait For Response keyword and then check if status code from response is 200. I tried:

${resp}=    Wait For Response   matcher=${URL}
Log To Console      ${resp}
${status}=  Set Variable    ${resp.status_code()}

but unfortunately I’ve got following error:
Resolving variable ‘${resp.status_code()}’ failed: AttributeError: ‘dict’ object has no attribute ‘status_code’ - is it any way to get status code from this response? I tried also ${resp.json([“status_code”]}, but it doesn’t work too.

As documentation says keyword returns python dictionary. So what you need is ${resp["status"]}.

1 Like