Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
test
autotest-airtest-web-cmdc
Commits
11bdbe75
Commit
11bdbe75
authored
Jan 10, 2024
by
liguangyu06
Browse files
优化
parent
7ae5bf48
Changes
2
Hide whitespace changes
Inline
Side-by-side
air_case/cmdc_buyercar_list/购物车新增商品.air/购物车新增商品.py
View file @
11bdbe75
...
...
@@ -10,6 +10,7 @@ from common.common_func import commonFuc
from
air_case.cmdc_login.多采商城登录.多采商城登录
import
CmdcMaiiLogin
from
air_case.cmdc_login.后台管理系统登录.后台管理系统登录
import
CmdcDoLogin
import
requests
import
random
import
json
...
...
@@ -25,15 +26,18 @@ headers = commonFuc().get_business_data(module, "json_headers", cmdc_access_toke
# 获取商品列表
url
=
commonFuc
().
get_api_url
()
+
commonFuc
().
get_business_data
(
module
,
"url20"
)
request_body
=
commonFuc
().
get_business_data
(
module
,
"payload20"
)
request_body
=
commonFuc
().
get_business_data
(
module
,
"payload20
_1
"
)
# 发送请求
result
=
requests
.
post
(
url
,
json
=
request_body
,
headers
=
headers
)
result
=
json
.
loads
(
result
.
content
)
# print(result)
# 生成随机数
product_random
=
random
.
randint
(
0
,
len
(
result
[
"data"
][
"list"
])
-
1
)
# 获取商品列表中的商品信息
product_id
=
result
[
"data"
][
"list"
][
0
][
"productId"
]
price
=
result
[
"data"
][
"list"
][
0
][
"referencePrice"
]
filiale_code
=
result
[
"data"
][
"list"
][
0
][
"filialeCode"
]
product_id
=
result
[
"data"
][
"list"
][
product_random
][
"productId"
]
price
=
result
[
"data"
][
"list"
][
product_random
][
"referencePrice"
]
filiale_code
=
result
[
"data"
][
"list"
][
product_random
][
"filialeCode"
]
# 第二步登录多采商城添加商品至购物车列表
# 获取登录所需账号密码
username1
=
commonFuc
().
get_business_data
(
module
,
"username"
)
...
...
@@ -58,7 +62,7 @@ result1 = json.loads(result1.content)
if
result1
[
"success"
]:
# 获取预期结果
check_dict
=
commonFuc
().
get_business_data
(
module
,
"checkDict2"
)
print
(
check_dict
)
#
print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc
().
check_result
(
check_dict
,
result1
)
else
:
...
...
data/cmdc_buyercar_list/data
View file @
11bdbe75
...
...
@@ -45,6 +45,7 @@ json_headers2: {
"url20": "/product/mall/queryProductInfoByPage"
#查询已上架商品列表请求报文
"payload20": {"isFbList":0,"filialeCode":null,"productName":null,"productCode":null,"specifications":null,"materialCode":null,"manufacturer":null,"lineName":null,"riskRank":null,"isRelease":"1","isExistImage":null,"jdeStatus":"P","isGift":"0","description":null,"tbsj":[],"pageNum":1,"pageSize":8,"total":453,"firstQuery":true,"flag":true,"preInvalidStatus":null,"isControlSales":"0","startTime":null,"endTime":null,"status":101}
"payload20_1": {"isFbList":0,"filialeCode":null,"productName":null,"productCode":null,"specifications":null,"materialCode":null,"manufacturer":null,"lineName":null,"riskRank":null,"isRelease":"1","isExistImage":null,"jdeStatus":"P","isGift":"0","description":null,"tbsj":[],"pageNum":1,"pageSize":8,"total":1641,"firstQuery":true,"flag":true,"preInvalidStatus":null,"isControlSales":"0","startTime":null,"endTime":null,"status":101}
#添加商品至购物车报文
"payload2": {"currentCompanyId":null,"productId":"%d","quantity":1,"agreementPriceId":null,"price":"%d","filialeCode":"%s"}
#预期结果
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment