传data和传json的qubie
被测对象,白月黑羽系统
系统下载地址:
https://www.byhy.net/prac/pub/info/bysms/
测试用例下载地址:
https://cdn2.byhy.net/files/selenium/testcases.xlsx
一、传data
import json
import requests
import pytest
import time
# def test_001(username,password):
url = "http://127.0.0.1/api/mgr/signin"
payload = "username=byhy&password=88888888"
# payload = {"username":"byhy","password":"88888888"}
headers = {
"Accept": "*/*",
"Accept-Language": "zh-CN,zh;q=0.9",
"Connection": "keep-alive",
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
"Origin": "http://127.0.0.1",
"Referer": "http://127.0.0.1/mgr/sign.html",
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "same-origin",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36",
"X-Requested-With": "XMLHttpRequest",
# "sec-ch-ua": ""Not/A)Brand";v="8", "Chromium";v="126", "Google Chrome";v="126"",
"sec-ch-ua-mobile": "?0",
# "sec-ch-ua-platform": ""Windows"",
"Cookie": "sessionid=04y7o3zegx65k3x6cufk5uuvfun2c7od",
"content-type": "application/x-www-form-urlencoded"
}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
二、传json
import json
import requests
import pytest
import time
# def test_001(username,password):
url = "http://127.0.0.1/api/mgr/signin"
payload = "username=byhy&password=88888888"
# payload = {"username":"byhy","password":"88888888"}
headers = {
"Accept": "*/*",
"Accept-Language": "zh-CN,zh;q=0.9",
"Connection": "keep-alive",
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
"Origin": "http://127.0.0.1",
"Referer": "http://127.0.0.1/mgr/sign.html",
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "same-origin",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36",
"X-Requested-With": "XMLHttpRequest",
# "sec-ch-ua": ""Not/A)Brand";v="8", "Chromium";v="126", "Google Chrome";v="126"",
"sec-ch-ua-mobile": "?0",
# "sec-ch-ua-platform": ""Windows"",
"Cookie": "sessionid=04y7o3zegx65k3x6cufk5uuvfun2c7od",
"content-type": "application/x-www-form-urlencoded"
}
response = requests.request("POST", url, json=payload, headers=headers)
print(response.text)