Read external files in Postman

Table of contents

Foreword:

1. The format of reading external files in postman

 2. How to import files in Postman

 3. Read the imported data file in Postman


Foreword:

In Postman, you can use the "Data Files" feature to read external files such as CSV, JSON or Excel files. This makes it more convenient and flexible to use a lot of different data in your tests.

1. The format of reading external files in postman

1、csv

(1) Advantages: ① Simple structure and wide application range

(2) Disadvantages: ① does not support bool type; ② does not support parameter exceptions; ③ does not support complex data types

2、json

(1) Advantages: ①Supports bool type; ②Supports parameter exceptions; ③Supports complex data types

(2) Disadvantages: ① Under the same circumstances, the file is much larger than csv

 2. How to import files in Postman

1. Import csv file

2. Import the json file

(1) The pre-steps are the same as importing csv, previewing the imported content

 3. Read the imported data file in Postman

1. Obtained from the request parameters

(1) Use { {}} to wrap fields or keys in the request header, line, and body

2. Obtained from the code

(1) Use the data. field (key) in the assertion and request pre-scripts

var a = pm.iterationData.get("withdrawlId");
console.log(a)
//json文件获取并设置变量
pm.variables.set('host', pm.iterationData.get('host'))
pm.variables.set('dbname', pm.iterationData.get('dbname'))
pm.variables.set('perpage', pm.iterationData.get('perpage'))

 As someone who has been here, I also hope that you will avoid some detours. Here I will share with you some necessities on the way forward for automated testing, hoping to help you. (WEB automated testing, app automated testing, interface automated testing, continuous integration, automated test development, big factory interview questions, resume templates, etc.), I believe it can make you better progress!

Just leave [Automated Test] [Automated Test Communication]: 574737577 (note ccc) http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=xDO13nzpfizFgd5LduYouVWGlfILKiID&authKey=TTzgMcMyNEfwu9lChmN9dw2zvAfj8PMIjxQhT23 zl5hUqtbxMMfbi%2BsdzFetfiq4&noverify=0&group_code=574737577

Guess you like

Origin blog.csdn.net/Free355/article/details/131455007