RobotFramework:运行API自动化时得到错误的状态代码

时间:2020-05-20 06:10:57

标签: selenium testing automation automated-tests robotframework

我正在尝试出于学习目的而建立API测试框架。当我尝试在RobotFramework中的虚拟API http://dummy.restapiexample.com/api/v1/employees上运行GET Request时,向我显示了错误的状态代码。我得到406

,如果我在浏览器或Postman中运行相同的请求。我会得到Success 200

这是我的代码:-

文件:-common.robot

*** Settings ***
Library          RequestsLibrary

*** Variables ***
${base_URL}       http://dummy.restapiexample.com
*** Keywords ***
User hit Get Request
    create session   rest_api_get_request     ${base_url}
    ${response}=    get request   rest_api_get_request  api/v1/employees
    log to console   ${response.url} ${response.status_code}

文件:-dummy.robot

*** Settings ***
Resource         ../Api/Keywords/common.robot

*** Test Cases ***
Test Dummy Get Request
    User hit Get Request

结果:-

enter image description here

0 个答案:

没有答案