Importing test library 'RequestsLibrary' failed: ImportError: No module named RequestsLibrary Traceback

Vishal Pachpute picture Vishal Pachpute · Dec 20, 2016 · Viewed 11.2k times · Source

I am hitting HTTP service using Robot. But it is showing me the following issues

  1. No keyword with name 'Create Session' found.

  2. Importing test library 'RequestsLibrary' failed: ImportError: No module named RequestsLibrary Traceback (most recent call last):

I have installed RequestsLibrary. My TC is:

*** Settings ***
Library  Collections
Library  String
#Library  RequestsLibrary
Library  OperatingSystem
Library    ExtendedRequestsLibrary
Suite    Teardown  Delete All Sessions

*** Test Cases ***
Get Requests
    [Tags]  get
    Create Session  google  http://www.google.com
#    Create Session  github  https://api.github.com

    ${resp}=  Get  google  /
    Should Be Equal As Strings  ${resp.status_code}  200

    ${resp}=  Get  github  /users/bulkan
    Should Be Equal As Strings  ${resp.status_code}  200
    Dictionary Should Contain Value  ${resp.json()}  Bulkan Evcimen

Answer

Todor Minakov picture Todor Minakov · May 3, 2017

The error is that the RequestLibrary is not installed, but the source you've posted actually imports ExtendedRequestsLibrary. You need to have it installed:

pip install robotframework-extendedrequestslibrary

The command to install RequestLibrary - the one that is commented - is:

pip install robotframework-requests

As the library (libraries) were not installed, you got the first error - the Create Session is defined in them, and w/o the library Robot Framework does not find it.