分析接口是屬于什么類型的

image.png
選擇對應(yīng)的模板-例如post 鍵值對數(shù)據(jù)

image.png
根據(jù)注釋修改成自己需要的用例

image.png
response的響應(yīng)斷言

image.png
def getdict(self,dict1,obj,default=None):
''' 遍歷嵌套字典,得到想要的value
dict1所需遍歷的字典
obj 所需value的鍵'''
for k,v in dict1.items():
if k == obj:
return v
else:
if type(v) is dict:#如果是字典
re = self.getdict(v,obj,default) # 遞歸
if re is not default:
return re
from Common.Base_test import webrequests
response = {'errno': 0, 'msg': 'success', 'result': {'id': '5b4dc7111c0ab20001c3c481', 'cname': '測試001', 'desc': '測試機(jī)器人', 'type': 0, 'settings': {'failAction': ['偶母雞啊', '我不告訴你']}, 'lastView': '2018-07-17T18:38:09.250849551+08:00', 'nickname': '小可愛', 'age': 0, 'gender': 'male', 'hometown': '北京', 'speciality': '打游戲'}}
s = webrequests()
failAction = s.getdict(response,'failAction')
print(failAction)