Robot Framework API testing - Create Session keyword not found

2.1k views Asked by At

I am trying to do API testing with Robot Framework as part of that,i am getting below error

No keyword with name 'createsession mysession' found.Can any body please help how to resolve this error.

I have installed below libraries. robotframework,request,robotframework-request,robotframework-jsonlibrary

Below is the code for the same

===============================================================================================
*** Settings ***
Library   RequestLibrary

*** Variables ***
${baseurl}   http://demoqa.com/utilities/
${endpoint}  weather/city/

*** Keywords ***

*** Test Cases ***
TestCaseone

  createsession mysession  ${baseurl}
  ${response}=  Get Request  mysession  ${endpoint}/bangalore
  log to console  ${response.status.code}
  log to console  ${response.status.body]
  log to console  ${response.header}
2

There are 2 answers

0
madi_madi On

Here's your code which I revised or edited Your issue was just space hence ${baseurl} was not being recognised. Just remember to use TAB instead of space with the robotframework and inspect API to use actual words that are part of the API response.

  *** Settings ***
  Library   RequestsLibrary

  *** Variables ***
  ${baseurl}   http://demoqa.com/utilities/
  ${endpoint}  weather/city/

  *** Keywords ***

  *** Test Cases ***
  TestCaseone
      createsession    mysession  ${baseurl}
      ${response}=     Get On Session  mysession  ${endpoint}/bangalore
      log to console   ${response.text}
      log to console   ${response.content}
      log to console   ${response.headers}
4
pavelsaman On

If your code really is formated like this:

createsession mysession  ${baseurl}

then no such keyword exists in RequestsLibrary.

You need to properly use whitespace, it does matter.

This should work:

Create Session mysession ${baseurl}

remember to type at least two spaces between the keyword and its arguments, and between arguments.