1.脚本断言,选择python


2.脚本代码
import json
# 脚本断言
def compare(actual, expect):
# 增加判断逻辑
# actual为当前步骤响应结果封装
# expect为期望结果封装
# Struct类型为平台定义,详见帮助文档
# json字符格式格式预处理,否则转json报错
jstr = str(actual).replace('\\"','')
jstr = jstr.replace('\\','')
jsonObj = json.loads(jstr)
# 遍历json集合数据
dataList = jsonObj['result']['data']
tempList = []
print("length:",len(dataList))
if len(dataList) > 0:
for GoodsList in dataList:
tmpValue = ""
try:
tmpValue = GoodsList['cid3Name']
except Exception as e:
pass
# print('异常数据:',GoodsList)
tempList.append(tmpValue)
print("cid3Name数据:",tempList)
# 定义Bool变量
ISflag = True
if len(tempList) <=0 :
ISflag = False
print(ISflag)
return ISflag;
断言成功,返回True, 失败则返回False