首页 > 解决方案 > 机器人框架工作错误导入测试库“Requestslibrary”失败:ModuleNotFoundError:没有名为“Requestslibrary”和“JSONlibrary”的模块

问题描述

我有两个文件,一个用于关键字,另一个用于运行实际的测试用例

testkeywords.robot

*** Settings ***
Library  Requestslibrary
Library  JSONlibrary
Library  Collections

*** Variables ***
${Base_URL}  http://www.thetestingworldapi.com/

*** Keywords ***
Get Student Name
    [Arguments]  ${id}
    create session  Get_student_details  ${base_url}
    ${response}=    get request  Get_student_details  api/studentsDetails/${id}
    #log to console  ${response.content}
    ${json_res}=    to json  ${response.content}
    #log to console  ${json_res}
    @{first_name_list}=  get value from json  ${json_res}  data.first_name
    ${first_name}=  get from list  ${first_name_list}  0
    [return]  ${first_name}



sample.robot



*** Settings ***
Library  RequestsLibrary
Library  JSONLibrary
Library  Collections
Resource  Resources/testkeywords.robot

*** Variables ***
${id}  56841

*** Test Cases ***
TC_01
    Get Student Name  ${id}

我收到错误错误“导入测试库'Requestslibrary'失败:ModuleNotFoundError:没有名为'Requestslibrary的模块”

但是在导入相同的库时,示例文件没有任何问题就被破坏了

标签: robotframework

解决方案


推荐阅读