領(lǐng)導(dǎo)要求刪除這個(gè)文件,在用例執(zhí)行的時(shí)候,直接從外部的excel讀取變量文件,于是用python+xlrd寫了下渺杉,記錄下
excel文件
當(dāng)Excute為Yes時(shí),導(dǎo)入此行的數(shù)據(jù)挪钓。
#coding=utf=8
import xlrd
import json
import sys
import os
reload(sys)
sys.setdefaultencoding("utf-8")
def get_data():
ff = xlrd.open_workbook('EnvronmentVariable.xlsx')
table = ff.sheet_by_index(0)
data = {}
for i in range(1, table.nrows):
if table.cell(i, 1).value != 'Yes':
continue
data['browser'] = str(table.cell(i, 2).value)
data['url'] = str(table.cell(i, 3).value)
data['dbhost'] = str(table.cell(i, 4).value)
data['dbport'] = str(int(table.cell(i, 5).value))
data['dbuser'] = str(table.cell(i, 6).value)
data['dbpassword'] = str(table.cell(i, 7).value)
data['dbapi'] = str(table.cell(i, 8).value)
data['blacksourcetype'] = str((table.cell(i, 9).value))
data['sourcetype'] = str(int(table.cell(i, 10).value))
data['statustype'] = str(int(table.cell(i, 11).value))
data['addnametype'] = str(int(table.cell(i, 12).value))
data['dbuser_con'] = str(table.cell(i, 13).value)
data['dbpwd'] = str(table.cell(i, 14).value)
data['db_ol_portal'] = str(table.cell(i, 15).value)
data['db_ol_portal_pwd'] = str(table.cell(i, 16).value)
return data
if __name__ == '__main__':
print get_data()
需要注意的是是越,xlrd會(huì)把提取出來(lái)的數(shù)字添加上小數(shù)點(diǎn),所以就直接轉(zhuǎn)成str碌上。
還需要在RF中寫一個(gè)關(guān)鍵字倚评,然后在suite setup中設(shè)置一下就好了