HttpRunner接口自动化踩过的坑

如题所述

第1个回答  2022-07-27
HttpRunner V2.x 中文使用文档



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语法入门教程:

yaml格式检测小工具:  

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

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网