找了一个不需要验证码登录的网站,康爱多网上药店,使用Python+requests框架实现接口自动化,选择登录-加购-下单-取消订单-删除订单一条业务链五个接口测试,代码如下:
import requests
import time
# 登录
session = requests.session()
body = {
'userName': 'xxxxxxxxxxx',
'pass': 'xxxxxxxxx'
}
login = session.post('https://user.360kad.com/Login/AjaxLoginV2', data=body)
print(login.text)
# 加入购物车
cartparam = {
'id': 1406,
'quantity': 1,
'buyType': 0,
'sellerCode': '',
'rd': 0.7634724674063651
}
cart = session.get('https://www.360kad.com/cart/AddCart', params=cartparam)
print(cart.text)
# 提交订单
orderdata = {
'AddressId': 11710216491,
'PayType': 1,
'InvoiceType': 0,
'InvoiceTitle': '',
'InvoiceCustomerType': 1,
'InvoiceDutyParagraph': '',
'IsInvoice': 0,
'CartType': 0,
'SendTimeType': 0,
'Remark': '',
'CouponCode': '',
'PointsAmt': 0,
'SendType': 1,
'IsFreightInsurance': 'false',
'IsExchangeInsurance': 'false'
}
order = session.post('https://cart.360kad.com/Order/CreateOrder', data=orderdata)
print(order.text)
time.sleep(3)
# 取消订单
orderid = order.json()['

本文通过Python的requests框架,演示了在康爱多网上药店进行接口自动化测试的过程,覆盖了登录、加购、下单、取消订单和删除订单等关键业务接口。测试结果表明流程完整,详细代码和测试资源分享供学习者参考。
最低0.47元/天 解锁文章
457

被折叠的 条评论
为什么被折叠?



