为什么我们不能一起运行 Get 请求方法与机器人框架中的请求库库



这是代码:

*** Settings ***
Library  Collections
Library  RequestsLibrary
Library  requests
# Declare Test case 
*** Test Cases ***
Get Requests2
    ${resp2}=   Get  http://services.groupkt.com/country/get/iso2code/IN
    ${convert_to_json2}=   set variable  ${resp2.json()}
    log to console  ${convert_to_json2}

它显示以下错误 找到名称为"Get"的多个关键字。提供要使用的关键字的全名:RequestsLibrary.Get requests。得到'

这些库可能都包含相同的关键字,或者更确切地说,它们都有一个使用相同名称的关键字。为了确定要调用哪个关键字,机器人框架在其关键字命名空间中只需要具有唯一的名称。

正如错误所暗示的那样,您可以在关键字名称之前添加库名称的前缀,以允许机器人框架区分两个关键字:

*** Test Cases ***
Get Requests2
    ${resp2}=   RequestsLibrary.Get  http://services.groupkt.com/country/get/iso2code/IN
    ${convert_to_json2}=   set variable  ${resp2.json()}
    log to console  ${convert_to_json2}

*** Test Cases ***
Get Requests2
    ${resp2}=   requests.Get  http://services.groupkt.com/country/get/iso2code/IN
    ${convert_to_json2}=   set variable  ${resp2.json()}
    log to console  ${convert_to_json2}

相关内容

最新更新