Skip to content

sabaao/PostmanTutorial

Repository files navigation

Postman tutorial and auto login

Skill

Html, Javascript, Chrome debug mode.

Postman install

Download and install from here.

Postman tutorial

Global variable and environment variable

environment variable

可以從右上角齒輪設定 manage environment

global variable

在不同的environment中共同使用 若environment variable跟global variable重複的話,會以environment為主

preScript and Tests process

process

Tests script

script sample

Mock Server

Create mock server

create mock server

Configuration mock server

config

Get mock server url

Postman will create a online mock server. mock server url

Add mock api

add mock api

Add response example

add response example save response example

Send mock api from postman

mock api

Send mock api from Chrome

mock api from Chrome

Monitor Server

Create Collection

Url is https://httpbin.org/json and add default test case of http 200. test collection

Create monitor

create monitor

Monitor configuration

Free account only can use hour timer. You can setting receive email when run fail. config create success

Run monitor

Open web page

Click monitor column will open monitor web page. open web page If click run button, it will create report. report

Auto send alert mail

Add a fail test case in test script.

pm.test("Your test name", function () {
    var jsonData = pm.response.json();
    pm.expect(jsonData.slideshow.author).to.eql("lalala");
});

And run it, you will receive alert mail.

alert mail

Demo auto login

Use Chrome debug mode

Setting->更多工具->開發人員工具(shortcut: command + option + i) chrome

Network

Review api history and detail.

network

Api detail information.

detail infomation

api list

checkin

checkout

Auto login Robo

Install nodejs

Download and install from here.

Verify nodejs install success

Open terimal, and input command.

node -v

If console show node's version, it mean you install success.

install newman plugin

npm install -g newman

Verify newman install success.

newman -v

Check in

newman run checkin.postman_collection.json --environment cathay.prod.postman_environment.json 

If you want how to set schedule in MacOS, you can reference this.

Check out

newman run checkout.postman_collection.json --environment cathay.prod.postman_environment.json 

You can set check out in Monitor server.

Create Robo on MacOS

Create an application on MacOS

Follow this article to create an application from shell script.

PATH="/usr/local/bin:$PATH"
/usr/local/bin/newman run /Users/caichengfu/Develop/github/PostmanTutorial/checkout.postman_collection.json -e /Users/caichengfu/Develop/github/PostmanTutorial/charles_cathay.postman_environment.json

automator

Set automation

Follow this article and install Scheduler for Macintosh. scheduler setting

Restrict

Must use cathaybk wifi.

Q & A

Q1. Why I can not use api login?

Answer

Someone will get 302 error when they login, it is server side bug, but I don't who will happen.

Q2. Account and password wrong.

Answer

You need modify cathay.prod.postman_environment.json. To change username and password.

Reverence

Monitor

Mock

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages