robotframeworkrobotframework-browser

How can I check the request method of a method in Robot Framework with Browser Library?


I am writing a keyword to delete a row of a to-do list and check that the row has been deleted. Is it possible for me to set up a promise that can verify if a DELETE request method has been used and if the response is a 200?

I'm thinking I can use the Wait For Response keyword, like this:

${promise}   Promise To    Wait For Response   **/todo/delete/{id}
Click    ${delete_button_locator}
Should Be Equal    ${promise}[method]    DELETE

Am I missing anything?


Solution

  • I have not used Wait For Response kw myself so not 100% but according to the documentation, you are on the right track. I'd go with something like this;

    
    ${promise}=    Promise To    Wait For Response    **/todo/delete/${id}  timeout=60s
    Click    ${delete_button_locator}
    ${response}=   Wait For        ${promise}            # Waits for the response
    Should Be Equal    ${response}[request][method]    DELETE
    

    Things to notice here, After clicking, response is explicitly waited with Wait For keyword and response is stored to variable. This variable is documented to to a dict of dicts and first key, request should contain the method..

    Anyway, this is just be reading the docs.