美文网首页
HttpRunner接口自动化踩过的坑

HttpRunner接口自动化踩过的坑

作者: 蹩脚诗人_Ww | 来源:发表于2020-11-21 17:38 被阅读0次

    HttpRunner V2.x 中文使用文档

    https://v2.httprunner.org/concept/nominal/

    1、

    脚本需要用到yaml模块,python3.X只能使用pip install pyyaml 来安装。直接安装yaml会报错:

    ERROR: Could not find a version that satisfies the requirement yaml (fro

    m versions: none)

    ERROR: No matching distribution found for yaml

    2、

    报错信息:httprunner.exceptions.ParamsError: Invalid testcase path or testcases: testcase/demo.yaml

          测试用例无效路径,因为conf.py内 用例地址设置不正确。要注意用例存放的路径,与conf.py文件里填写的路径是否一致。

    3、

    报错time_start,因为yaml格式不正确。

    直接用抓包工具导入的文件,格式需要调整,不然程序无法运行。HttpRunner只内置了 JSON 格式正确性检测和样式美化功能,对于YAML 格式的用例,需要人为控制 YAML 格式没有语法错误。

    yaml语法入门教程:https://www.runoob.com/w3cnote/yaml-intro.html

    yaml格式检测小工具:  http://www.yamllint.com/

    4.

    报错信息:

    yaml.parser.ParserError: expected '<document start>', but found '<block sequence start>'

      in "demo.yaml", line 43, column 1

    yaml格式问题,yaml不支持多行注释,只能使用#。文档中使用了''' ''' 多行注释之后报错。改为# 之后正常。

    5、报错信息:

    yaml.scanner.ScannerError: while scanning for the next token

    found character '%' that cannot start any token

    yaml不支持%符号,params参数解码格式改为中文。

    6、报错信息:

    yaml.parser.ParserError: while parsing a flow sequence

      in "demo.yaml", line 139, column 13

    expected ',' or ']', but got '{'

      in "demo", line 139, column 47

    引用extract里的参数,时使用了 ${} 所以报错。 仅需要在$符号后直接跟参数名

    7.报错信息:

    httprunner.exceptions.ExtractFailure: Failed to extract! => data.config.0.time

    由于提取的语句错误,导致无法提取到参数

    错误:content.data.time

    正确:content.data.0.time

    相关文章

      网友评论

          本文标题:HttpRunner接口自动化踩过的坑

          本文链接:https://www.haomeiwen.com/subject/zrseiktx.html