【问题标题】:Robot Framework : Try to compare values of two json files机器人框架:尝试比较两个 json 文件的值
【发布时间】:2020-07-12 23:40:40
【问题描述】:

我在比较我的 json 文件中的任何值与 robotsFramework 中的响应响应时遇到了一些困难。

两者都是 json :

${enterprise_json}=     Evaluate        json.dumps(${input_enterprise_json})       json
${response_json}=     Evaluate        json.dumps(${response_body})       json

我尝试使用 for 循环,但返回失败:

${input_enterprise_json}=     Input       ${FILE_ENTERPRISE_JSON}

${enterprise_json}=     Evaluate        json.dumps(${input_enterprise_json})       json
${response_json}=     Evaluate        json.dumps(${response_body})       json

:FOR        ${item}     IN      ${enterprise_json}
    Should Contain Any      ${response_json}        ${item}        
END

结果:

Test Execution Log

您有参考/解决方案进行测试吗?

【问题讨论】:

    标签: json for-loop robotframework


    【解决方案1】:

    或者...是否可以只保留我的 Json 文件的键值?

    @{list}=        Create List     @{list_values_of_my_json_file}
    FOR     ${item}     IN      ${response_json}
        Should Contain      ${item}        @{list}
        # or Should Contain Any
    END
    

    Explanation Code

    【讨论】:

      猜你喜欢
      • 2016-08-23
      • 2020-07-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-25
      • 2013-07-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多