基于网页接口做自动化测试(基于HttpRunner+Fiddler)

编程

1.安装Fiddler ,可以参考 http://together-learn.com/post/263

2.安装 HttpRunner,我在windows做的测试,前置条件:安装了 python 和 pip

pip install httprunner

3.通过Fiddler,录制接口请求

4.导出 请求会话  .har 格式文件

5.har文件转换为 HttpRunner需要的测试用例文件

har2case index.har -2y

注意:如果有https请求,在teststeos - request 下面 添加

verify: False,如下

config:

name: testcase description

variables: {}

teststeps:

- name: /skin/jkj/css/navlist.css

request:

headers:

User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML,

like Gecko) Chrome/73.0.3683.86 Safari/537.36

method: GET

url: https://www.cn-healthcare.com/skin/jkj/css/navlist.css

verify: False

validate:

- eq:

- status_code

- 302

- eq:

- headers.Content-Type

- text/html

- name: /api/getsignature

request:

headers:

If-None-Match: W/"8b-e7NKoutVtiIjmwo8g97hsg"

User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML,

like Gecko) Chrome/73.0.3683.86 Safari/537.36

X-Requested-With: XMLHttpRequest

method: GET

params:

url: https://www.cn-healthcare.com/

url: https://www.cn-healthcare.com/api/getsignature

validate:

- eq:

- status_code

- 200

- eq:

- headers.Content-Type

- application/json; charset=utf-8

- eq:

- content.appId

- wx71aec0aae5f6883a

- eq:

- content.timestamp

- "1573711790"

- eq:

- content.nonceStr

- 2iuiyokvdubit3x

- eq:

- content.signature

- 130967aff5dfa383e9c900759ec6af473a660571

6.启动测试

hrun index.yml

7.查看测试报告,第六步执行成功后,会在同目录下生成reports文件夹

 

参考文档:

https://docs.httprunner.org/

以上是 基于网页接口做自动化测试(基于HttpRunner+Fiddler) 的全部内容, 来源链接: utcz.com/z/510768.html

回到顶部