6

我正在使用 Robot 访问 HTTP 服务。但它向我展示了以下问题

  1. 未找到名称为“创建会话”的关键字。

  2. 导入测试库“RequestsLibrary”失败:ImportError:没有名为 RequestsLibrary Traceback 的模块(最后一次调用):

我已经安装了 RequestsLibrary。我的TC是:

*** 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
4

1 回答 1

11

错误是未安装 RequestLibrary,但您发布的源实际上导入了 ExtendedRequestsLibrary。您需要安装它:

pip install robotframework-extendedrequestslibrary

安装 RequestLibrary 的命令 - 被评论的 - 是:

pip install robotframework-requests

由于未安装库(库),因此您遇到了第一个错误 -Create Session已在其中定义,并且没有库 Robot Framework 找不到它。

于 2017-05-03T07:59:10.740 回答