Test fails using new keywords GET On Session , DELETE On Session

I am new to Robot Framework and was experimenting with some examples from Test Automation University.

The examples work fine with the old keywords Get Request and Delete Request. But when I change them to GET On Session and DELETE On Session the test fails in the last GET On Session with an HTTPError: 404 Client Error

This is the code from the test file:
*** Settings ***
Library SeleniumLibrary
Library OperatingSystem
Library RequestsLibrary
Library String
Library Collections

Suite Setup Run Keywords
Suite Teardown Run Keywords Close Browser

*** Test Cases ***
Create an Invoice
my Keyword
Open Browser chrome
${invoiceId}= Generate Random String 10 [LETTERS]
Set Suite Variable ${invoiceId}
Set Selenium Speed 0.5 Seconds
Click Link Add Invoice
Page Should Contain Element invoiceNo_add
Input Text invoice ${invoiceId}
Input Text company my example company
Input Text type plumbing
Input Text price 34.00
Input Text dueDate 2018-10-31
Input Text comment Unclogged Drain
Select From List By Value selectStatus Past Due
Click Button createButton
Create Session invoice-manager
${resp}= GET On Session invoice-manager /invoices/${invoiceId}
Should Be Equal As Strings ${resp.status_code} 200
Dictionary Should Contain Value ${resp.json()} ${invoiceId}
${resp}= DELETE On Session invoice-manager /invoices/${invoiceId}
Should Be Equal As Strings ${resp.status_code} 200
${resp}= GET On Session invoice-manager /invoices/${invoiceId}
Should Be Equal As Strings ${resp.status_code} 404

*** Keywords ***
my Keyword Comment this is keyword I created

I’ve compared the test results from both versions:

Any idea what’s wrong?

In both cases you are getting a 404 response for the line

${resp}=    GET On Session    invoice-manager    /invoices/${invoiceId}

and indeed that looks to be what you expected to get, but it appears that GET On Session is treating this as a failure (4xx and 5xx are usually failure statuses where 2xx 3xx are not) but the old Get Request did not.

There appears to be mentioned of the documentation for GET On Session

By default this keyword fails if a status code with error values is returned in the response, this behavior can be modified using the expected_status and msg parameters, read more about it in Status Should Be keyword documentation. In order to disable this implicit assert mechanism you can pass as expected_status the values any or anything .

You should probably use

${resp}=    GET On Session    invoice-manager    /invoices/${invoiceId}    expected_status=404


${resp}=    GET On Session    invoice-manager    /invoices/${invoiceId}    expected_status=any

I would prefer to use expected_status=404 because it will let you eliminate the line

Should Be Equal As Strings ${resp.status_code} 404

As GET On Session is already doing that test for you.

Hope this helps,


Thanks for your help, Dave.

Adding expected_status=404 did the trick.

Still its odd that ‘GET Request’ doesn’t run into the same issue as GET On Session when both are supposed to do the same thing.
You’ld think that the updated keyword would at least produce the same result and is an enhancement of the ‘old’ keyword.

Thanks again for your help.


While it’s not clear, the paragraph I quoted for GET On Session, was not in GET Request, so I guess that implies that GET Request doesn’t do any validation and the validation mentioned in GET On Session is a new feature.

Anyway glad I could help you solve your issue.


It’s exactly as you wrote. This behavior is an enhancement of the new keywords.

I will try to figure it out for more. Keep sharing such informative post keep suggesting such post.