httprunner 3.X (5)variables变量优先
2022-01-14 本文已影响0人
Sandra_liu
1)配置变量->全局变量
config = Config("登录 ") \
.variables(
**{
"user_name": "${ENV(USERNAME)}",
"password": "${ENV(PASSWORD)}",
}
)
2)导出变量->将局部变量变成全局变量
config = Config("登录 ") \
.variables(
**{
"user_name": "${ENV(USERNAME)}",
"password": "${ENV(PASSWORD)}",
}
) \
.export("token")
3)参数变量->局部变量
.with_json({"account": "$user_name", "password": "$password"})
4)提取变量->局部变量
.extract()
.with_jmespath("body.user_id", "user_id")
.with_jmespath("body.token", "token")