美文网首页python
python自动化之获取excel数据

python自动化之获取excel数据

作者: gaby666 | 来源:发表于2019-08-09 08:01 被阅读0次

一般情况下,测试用例是保存在excel文件中,通过获取excel文件数据判断用例是否知晓,执行参数等
1.请求参数体,比如请求参数在几行几列是一个json格式的参数
def get_request_data(self,row):
col = int(data_config.get_data())
data = self.opera_excel.get_cell_value(row,col)
if data == '':
return None
return data
2.获取预期结果,预期结果一般是请求参数,url,请求方式都获取,通过执行request,得到返回的数据response,代码如下
def get_expcet_data(self,row):
col = int(data_config.get_expect())
expect = self.opera_excel.get_cell_value(row,col)
if expect == '':
return None
return expect
3.通过sql获取预期结果,通过输入一个sql语句,在数据库中返回预期结果,即为预期结果
def get_expcet_data_for_mysql(self,row):
op_mysql = OperationMysql()
sql = self.get_expcet_data(row)
res = op_mysql.search_one(sql)
return res.decode('unicode-escape')
4.除了当前的excel请求数据,预期结果之外,通过获取当前数据依赖字段,返回依赖值
def get_depend_field(self,row):
col = int(data_config.get_field_depend())
data = self.opera_excel.get_cell_value(row,col)
if data == "":
return None
else: return data

相关文章

网友评论

    本文标题:python自动化之获取excel数据

    本文链接:https://www.haomeiwen.com/subject/ykoqjctx.html