def operate_element(self, br, username, password, locate_element, element): """ 该函数主要是在浏览器内对定位到的元素进行操作 """ obj = locate_element username_send = username password_send = password readexcel_class3 = ReadExcel.ReadExcel() operate_excelpath = "F:\\pytest\\testauto\\Data\\operate_method.xls" operate_method_sheet = readexcel_class3.getTable(operate_excelpath) operate_method_sheet_rows = readexcel_class3.getExcelRows( operate_excelpath) operate_method_sheet_cols = readexcel_class3.getExcelCols( operate_excelpath) objectname_list = operate_method_sheet.col_values(0) # print objname if obj in objectname_list: for i in range(operate_method_sheet_rows): if objectname_list[i] == obj: list5 = operate_method_sheet.row_values(i) if list5[1] == 'sendkey' and obj == 'username': element.clear() element.send_keys(username_send) time.sleep(5) elif list5[1] == 'sendkey' and obj == 'password': element.clear() element.send_keys(password_send) time.sleep(5) elif list5[1] == 'click': element.click() time.sleep(10) else: print("该元素没有在caozuo.xls文件中")
def getRows(self): """ 得到本次测试内容的总行数 """ excel_path = "E:\\testData\\interface_test.xls" rows = ReadExcel.ReadExcel().getExcelRows(excel_path) return rows
def getRegisterDataByTestcaseId(self, testcaseid): register_exclepath = "F:\\pytest\\xebest-autotest\\Data\\registerByPhoneNumber_data.xls" register_sheetname = "register_data" register_sheet = ReadExcel.ReadExcel().getTableBySheetName( register_exclepath, register_sheetname) row_col_number_list = get_number_by_data.GetRowAndColNumber( ).getRowAndColNumber(register_exclepath, register_sheetname, testcaseid) # email-address:邮箱地址,loginpassword:登录密码,reloginpassword:确认登录密码,phonenumber:手机号码,smscheckcode:短信验证码 # picturecheckcode:图片验证码 element_list = [ 'email-address', 'loginpassword', 'reloginpassword', 'phonenumber', 'smscheckcode', 'picturecheckcode' ] register_data_list = [] col_index = 2 for i in range(element_list.__len__()): register_data_list.append( register_sheet.cell_value(row_col_number_list[0], (row_col_number_list[1]) + col_index)) col_index += 1 return register_data_list
def getAddProductDataByTestcaseid(self, testcaseid): """根据传递过来得testcaseid去拿到发布产品所需要填写的内容""" excel = ReadExcel.ReadExcel() testcase_excelpath = "F:\\pytest\\editAutotest\\Data\\addProduct_data.xls" testcase_sheet = excel.getTableBySheetName(testcase_excelpath, "addproduct_data") row_col_number_list = get_number_by_data.GetRowAndColNumber( ).getRowAndColNumber(testcase_excelpath, "addproduct_data", testcaseid) data_list = [] # product_title:产品标题,key_word:关键词,standard:规格,producter:生产厂家,quality_date:保质期,storage_conditions:存储条件 # product_allow_id:生产许可证号,product_standard_id:产品标准号,shop_price:批发价,retail_price:零售价 # supply_amount:供货量,min_amount:最小起订量,sendproduct_limit:发货期限,picture_path:图片地址,product_summary:产品简介,check_code:验证码 element_list = [ 'product_title', 'key_word', 'standard', 'producter', 'quality_date', 'storage_conditions', 'product_allow_id', 'product_standard_id', 'shop_price', 'retail_price', 'supply_amount', 'min_amount', 'sendproduct_limit', 'picture_path', 'product_summary', 'check_code' ] col_index = 2 for i in range(element_list.__len__()): element_list[i] = testcase_sheet.cell_value( row_col_number_list[0], row_col_number_list[1] + col_index) col_index += 1 for index in range(element_list.__len__()): data_list.append(element_list[index]) return data_list
def getLocateMethodAndData(self,element): excel=ReadExcel.ReadExcel() element_excel_path="F:\\pytest\\xebest-autotest\\Data\\send_goods.xls" element_sheet=excel.getTableBySheetName(element_excel_path,"objname_locatemethod_locatedata") #得到元素所在行号 row_index=get_number_by_data.GetRowAndColNumber().getRowAndColNumber(element_excel_path,"objname_locatemethod_locatedata",element)[0] #得到定位方式所在列号 locate_method_key=u"定位方式简述" locate_method_col_index=get_number_by_data.GetRowAndColNumber().getRowAndColNumber(element_excel_path,"objname_locatemethod_locatedata",locate_method_key)[1] #得到定位所需数据所在列号 locate_data_key=u"定位所需数据" locate_data_col_index=get_number_by_data.GetRowAndColNumber().getRowAndColNumber(element_excel_path,"objname_locatemethod_locatedata",locate_data_key)[1] #得到元素是否需要二次定位的标志 second_locate=u"是否需要二次定位" is_second_locate=get_number_by_data.GetRowAndColNumber().getRowAndColNumber(element_excel_path,'objname_locatemethod_locatedata',second_locate)[1] locate_method_dict={'id':By.ID,'css':By.CSS_SELECTOR,'xpath':By.XPATH,'linktext':By.LINK_TEXT,'classname':By.CLASS_NAME} old_first_how=element_sheet.cell_value(row_index,locate_method_col_index) what=element_sheet.cell_value(row_index,locate_data_col_index) new_first_how=locate_method_dict[old_first_how] judgeIsSecondLocate_flag=LocateElementCommonClass.CommonClass().judgeSecondLocateElement(is_second_locate) if not(judgeIsSecondLocate_flag): pass
def operateElement(self, br, object_name, located_element, username, password, alertmessage): """该函数作用就是去操作已经定位到的元素,操作方式为sendkey或者click """ br = br object_name = object_name located_element = located_element excel = ReadExcel.ReadExcel() operate_method_excelpath = "F:\\pytest\\xebest-autotest\\Data\\login_data.xls" operate_method_sheet = excel.getTableBySheetName( operate_method_excelpath, "operate_method") row_col_number_list = get_number_by_data.GetRowAndColNumber( ).getRowAndColNumber(operate_method_excelpath, "operate_method", object_name) operate_method = operate_method_sheet.cell_value( row_col_number_list[0], row_col_number_list[1] + 1) print object_name if operate_method == 'click': located_element.click() time.sleep(5) elif operate_method == 'sendkey' and object_name == 'username': located_element.clear() located_element.send_keys(username) print username time.sleep(5) elif operate_method == 'sendkey' and object_name == 'password': located_element.clear() located_element.send_keys(password) print password time.sleep(5)
def getLocatDataAndMethod(self, element, zhuce_element_list, excel_path, name_sheet_list): # path_excel=Get_ExcelPath_SheetName.Get_ExcelPath_SheetName().getExcelPath("F:\\Community_DD\\Data\\zhuce.xls","excelpath_sheetname") # name_sheet=(Get_ExcelPath_SheetName.Get_ExcelPath_SheetName().GetSheetName("F:\\Community_DD\\Data\\zhuce.xls","excelpath_sheetname"))[0] sheeet = ReadExcel.ReadExcel().getTableBySheetName( excel_path, name_sheet_list[0]) row_col_index = get_number_by_data.GetRowAndColNumber( ).getRowAndColNumber(excel_path, name_sheet_list[0], element) old_how = sheeet.cell_value(row_col_index[0], (row_col_index[1] + 1)) what = sheeet.cell_value(row_col_index[0], (row_col_index[1] + 2)) #在这里增加一个字典是因为如果直接把By.ID写在excel里的话,取出来不能用 locate_method_dict = { 'id': By.ID, 'css': By.CLASS_NAME, 'xpath': By.XPATH, 'linktext': By.LINK_TEXT, 'swipe': 'swipe' } new_how = locate_method_dict[old_how] how_what = [] how_what.append(element) how_what.append(new_how) how_what.append(what) how_what.append( self.getOperateMethod(element, excel_path, name_sheet_list)) how_what.append( self.assertMoreLocate(element, excel_path, name_sheet_list)) return how_what
def getPostUrl(self, row_index, col_index): """ 得到提交请求的地址 """ excel_path = "E:\\testData\\interface_test.xls" post_url = ReadExcel.ReadExcel().getValue(excel_path, row_index, col_index) return post_url
def judgeElementIsOperate(self,objname): judge_excelpath="F:\\pytest\\xebest-autotest\\Data\\registerByPhoneNumber_data.xls" judge_sheetname="isoperateElement" judge_sheet=ReadExcel.ReadExcel().getTableBySheetName(judge_excelpath,judge_sheetname) row_col_list=get_number_by_data.GetRowAndColNumber().getRowAndColNumber(judge_excelpath,judge_sheetname,objname) if judge_sheet.cell_value(row_col_list[0],(row_col_list[1]+1))=="Y": return True else: return False
def getData(self, element_key): login_excel_path = r"F:\AutotestCode\Data\login_data.xls" login_sheetname = "username_password_data" sheet = ReadExcel.ReadExcel().getTableBySheetName( login_excel_path, login_sheetname) row_col_list = get_number_by_data.GetRowAndColNumber( ).getRowAndColNumber(login_excel_path, login_sheetname, element_key) data = sheet.cell_value(row_col_list[0] + 1, (row_col_list[1])) return data
def getObjList(self): readexcel_class1 = ReadExcel.ReadExcel() #实例化读取excel的类 object_excelpath = "F:\\pytest\\testauto\\Data\\objectname_locatemethod_locatedata.xls" object_sheet = readexcel_class1.getTable(object_excelpath) object_sheet_rows = object_sheet.nrows object_name_list = [] #得到需要定位的元素的名称的列表 for i in range(object_sheet_rows): #拿到登录功能中需要定位的对象名称列表 object_name_list.append(object_sheet.cell(i, 0).value) object_name_list.pop(0) #去掉对象名excel中的第一行的标签项名称 return object_name_list
def getOperateMethod(self, login_object): login_excel_path = r"F:\AutotestCode\Data\login_data.xls" login_sheetname = "operate_method" sheet = ReadExcel.ReadExcel().getTableBySheetName( login_excel_path, login_sheetname) row_col_list = get_number_by_data.GetRowAndColNumber( ).getRowAndColNumber(login_excel_path, login_sheetname, login_object) operate_method = sheet.cell_value(row_col_list[0], (row_col_list[1] + 1)) return operate_method
def getLocateElement(self): excel=ReadExcel.ReadExcel() element_excel_path="F:\\pytest\\xebest-autotest\\Data\\send_goods.xls" element_sheet=excel.getTableBySheetName(element_excel_path,"objname_locatemethod_locatedata") rows=element_sheet.nrows element_data_list=[] for i in range(1,rows): element_data_list.append(element_sheet.cell_value(i,0)) for element in element_data_list: self.getLocateMethodAndData(element)
def getOperateMethod(self, objname): register_exclepath = "F:\\pytest\\xebest-autotest\\Data\\register_data.xls" register_sheetname = "operate_method" register_sheet = ReadExcel.ReadExcel().getTableBySheetName( register_exclepath, register_sheetname) row_col_list = get_number_by_data.GetRowAndColNumber( ).getRowAndColNumber(register_exclepath, register_sheetname, objname) element_operate_method = register_sheet.cell_value( row_col_list[0], (row_col_list[1] + 1)) return element_operate_method
def getOperateMethod(self, element, excel_path, name_sheet_list): # path_excel=Get_ExcelPath_SheetName.Get_ExcelPath_SheetName().getExcelPath("F:\\Community_DD\\Data\\zhuce.xls","excelpath_sheetname") # name_sheet=(Get_ExcelPath_SheetName.Get_ExcelPath_SheetName().GetSheetName("F:\\Community_DD\\Data\\zhuce.xls","excelpath_sheetname"))[1] sheet = ReadExcel.ReadExcel().getTableBySheetName( excel_path, name_sheet_list[1]) row_col_list = get_number_by_data.GetRowAndColNumber( ).getRowAndColNumber(excel_path, name_sheet_list[1], element) operate_method_data = sheet.cell_value(row_col_list[0], (row_col_list[1] + 1)) return operate_method_data
def getRegisterObjectLocateMethod(self,browser,register_data_list,register_object): register_exclepath="F:\\pytest\\xebest-autotest\\Data\\registerByPhoneNumber_data.xls" register_sheetname="objname_locatemethod_locatedata" register_sheet=ReadExcel.ReadExcel().getTableBySheetName(register_exclepath,register_sheetname) row_col_list=get_number_by_data.GetRowAndColNumber().getRowAndColNumber(register_exclepath,register_sheetname,register_object) old_how=register_sheet.cell_value(row_col_list[0],(row_col_list[1]+1)) what=register_sheet.cell_value(row_col_list[0],(row_col_list[1]+2)) #在这里增加一个字典是因为如果直接把By.ID写在excel里的话,取出来不能用 locate_method_dict={'id':By.ID,'css':By.CSS_SELECTOR,'xpath':By.XPATH,'linktext':By.LINK_TEXT} new_how=locate_method_dict[old_how] self.locateRegisterObject(browser,register_data_list,register_object,new_how,what)
def getQuotePriceDataByTestcaseId(self,testcaseId): excel=ReadExcel.ReadExcel() testcase_excelpath="F:\\pytest\\xebest-autotest\\Data\\quoteprice_data.xls" testcase_sheet=excel.getTableBySheetName(testcase_excelpath,"quoteprice_data") send_data_list=[] row_col_number_list=get_number_by_data.GetRowAndColNumber().getRowAndColNumber(testcase_excelpath,"quoteprice_data",testcaseId) cols=testcase_sheet.ncols for i in range(2,cols): send_data_list.append(testcase_sheet.cell_value(row_col_number_list[0],i)) return send_data_list
def getData(self, element_key, path_excel, name_sheet_list): # path_excel=Get_ExcelPath_SheetName.Get_ExcelPath_SheetName().getExcelPath("F:\\Community_DD\\Data\\zhuce.xls","excelpath_sheetname") # name_sheet=(Get_ExcelPath_SheetName.Get_ExcelPath_SheetName().GetSheetName("F:\\Community_DD\\Data\\zhuce.xls","excelpath_sheetname"))[2] sheet = ReadExcel.ReadExcel().getTableBySheetName( path_excel, name_sheet_list[2]) row_col_list = get_number_by_data.GetRowAndColNumber( ).getRowAndColNumber(path_excel, name_sheet_list[2], element_key) data = sheet.cell_value(row_col_list[0] + 1, (row_col_list[1])) if type(data) == float: return int(data) else: return data
def getSendData(self, testcaseId): excel = ReadExcel.ReadExcel() send_data_path = "F:\\pytest\\xebest-autotest\\Data\\pay_by_balance.xls" send_data_sheet = excel.getTableBySheetName(send_data_path, "pay_by_balance") cols = send_data_sheet.ncols #得到测试用例id所在的行号 row_index = get_number_by_data.GetRowAndColNumber().getRowAndColNumber( send_data_path, "pay_by_balance", testcaseId)[0] send_data_list = [] for i in range(2, cols): send_data_list.append(send_data_sheet.cell_value(row_index, i)) return send_data_list
def getUsernameAndPasswordList(self): readexcel_class1 = ReadExcel.ReadExcel() #实例化读取excel的类 senddata_excelpath = "F:\\pytest\\testauto\\Data\\username_password.xls" senddata_sheet = readexcel_class1.getTable(senddata_excelpath) senddata_sheet_rows = senddata_sheet.nrows username_password_list = [] for i in range(1, senddata_sheet_rows): username_password_list.append( senddata_sheet.row_values(i)) #拿到存储在excel中存储的用户名和密码列表对 return username_password_list # pp=GetAndOperateLoginData() # pp.getAndOperateData()
def getUsernameAndPasswordByTestcaseid(self,testcaseid): """根据传递过来得testcaseid去拿到用户名、密码、弹出框内容""" excel=ReadExcel.ReadExcel() testcase_excelpath="F:\\pytest\\editAutotest\\Data\\login_data.xls" testcase_sheet=excel.getTableBySheetName(testcase_excelpath,"username_password_data") row_col_number_list=get_number_by_data.GetRowAndColNumber().getRowAndColNumber(testcase_excelpath,"username_password_data",testcaseid) data_list=[] user_name=testcase_sheet.cell_value(row_col_number_list[0],row_col_number_list[1]+2) pass_word=testcase_sheet.cell_value(row_col_number_list[0],row_col_number_list[1]+3) alert_message=testcase_sheet.cell_value(row_col_number_list[0],row_col_number_list[1]+4) data_list.append(user_name) data_list.append(pass_word) data_list.append(alert_message) return data_list
def getOperateMethod(self, element): excel = ReadExcel.ReadExcel() operateElement_excel_path = "F:\\pytest\\xebest-autotest\\Data\\send_goods.xls" operateElement_sheet = excel.getTableBySheetName( operateElement_excel_path, "operate_method") #得到操作方式所在列 operate_method_key = u"操作方式" operate_method_col_index = get_number_by_data.GetRowAndColNumber( ).getRowAndColNumber(operateElement_excel_path, "operate_method", operate_method_key)[1] #得到需要定位的元素所在的行号 row_index = get_number_by_data.GetRowAndColNumber().getRowAndColNumber( operateElement_excel_path, "operate_method", element)[1]
def getLocateObject(self,browser,register_data_list): register_exclepath="F:\\pytest\\xebest-autotest\\Data\\registerByPhoneNumber_data.xls" register_sheetname="objname_locatemethod_locatedata" register_sheet=ReadExcel.ReadExcel().getTableBySheetName(register_exclepath,register_sheetname) register_object_list=[] register_object_rows=register_sheet.nrows for i in range(register_object_rows): register_object_list.append(register_sheet.cell_value(i,0)) register_object_list.pop(0) for obj in register_object_list: if self.judgeElementIsOperate(obj): self.getRegisterObjectLocateMethod(browser,register_data_list,obj) else: print (u"本次不操作元素:")+obj
def getSendDataList(self, testcaseId): excel = ReadExcel.ReadExcel() sendGoods_excel_path = "F:\\pytest\\xebest-autotest\\Data\\send_goods.xls" sendGoods_sheet = excel.getTableBySheetName(sendGoods_excel_path, "send_goods") sendGoods_data_list = [] #得到测试用例编号所在行号 row_index = get_number_by_data.GetRowAndColNumber().getRowAndColNumber( sendGoods_excel_path, "send_goods", testcaseId)[0] cols = sendGoods_sheet.ncols for i in range(2, cols): sendGoods_data_list.append(sendGoods_sheet.cell_value( row_index, i)) return sendGoods_data_list
def assertMoreLocate(self, element, excel_path, name_sheet_list): # path_excel=Get_ExcelPath_SheetName.Get_ExcelPath_SheetName().getExcelPath("F:\\Community_DD\\Data\\zhuce.xls","excelpath_sheetname") # name_sheet=(Get_ExcelPath_SheetName.Get_ExcelPath_SheetName().GetSheetName("F:\\Community_DD\\Data\\zhuce.xls","excelpath_sheetname"))[0] sheet = ReadExcel.ReadExcel().getTableBySheetName( excel_path, name_sheet_list[0]) row_col_list = get_number_by_data.GetRowAndColNumber( ).getRowAndColNumber(excel_path, name_sheet_list[0], element) isMoreLocate = sheet.cell_value(row_col_list[0], (row_col_list[1] + 3)) second_Locate_Index = "" if isMoreLocate == 'Y': second_Locate_Index = int( sheet.cell_value(row_col_list[0], (row_col_list[1] + 4))) return second_Locate_Index else: return 0
def judgeElementIsOperate(self,element,testcase_id): excel=ReadExcel.ReadExcel() excel_path="F:\\pytest\\xebest-autotest\\Data\\deal_order.xls" excel_sheet=excel.getTableBySheetName(excel_path,"isoperateElement") #得到元素所在的行号 row_index=get_number_by_data.GetRowAndColNumber().getRowAndColNumber(excel_path,"isoperateElement",element)[0] #得到测试用例所在的列号 col_index=get_number_by_data.GetRowAndColNumber().getRowAndColNumber(excel_path,"isoperateElement",testcase_id)[1] operateFlag=excel_sheet.cell_value(row_index,col_index) if operateFlag=="Y": return True else: return False
def getLocateObject(self, browser, username, password, alertmessage): """循环需要定位的元素,拿到一个元素之后去调用getLocatMethodAndData方法,取得元素的定位方式以及定位所需数据""" browser = browser excel = ReadExcel.ReadExcel() object_excelpath = "F:\\pytest\\xebest-autotest\\Data\\login_data.xls" object_sheet = excel.getTableBySheetName( object_excelpath, "objname_locatemethod_locatedata") object_sheet_rows = object_sheet.nrows object_name_list = [] #得到需要定位的元素的名称的列表 for i in range(object_sheet_rows): #拿到登录功能中需要定位的对象名称列表 object_name_list.append(object_sheet.cell(i, 0).value) object_name_list.pop(0) #去掉对象名excel中的第一行的标签项名称 #循环需要定位的元素,拿到一个元素之后去调用getLocatMethodAndData方法,取得元素的定位方式以及定位所需数据 for object_name in object_name_list: self.getLocateMethodAndData(browser, object_name, username, password, alertmessage)
def getLocateMethodAndData(self,br,element): element=element excel=ReadExcel.ReadExcel() object_excel_path="F:\\pytest\\xebest-autotest\\Data\\deal_order.xls" object_sheet=excel.getTableBySheetName(object_excel_path,"objname_locatemethod_locatedata") #得到元素所在行 row_index=get_number_by_data.GetRowAndColNumber().getRowAndColNumber(object_excel_path,"objname_locatemethod_locatedata",element)[0] #得到定位方式所在列 locateMethod_Key=u"定位方式简述" locateMethod_colNumber=get_number_by_data.GetRowAndColNumber().getRowAndColNumber(object_excel_path,"objname_locatemethod_locatedata",locateMethod_Key)[1] #得到定位所需数据所在列 locateData_key=u"定位所需数据" locateData_colNumber=get_number_by_data.GetRowAndColNumber().getRowAndColNumber(object_excel_path,"objname_locatemethod_locatedata",locateData_key)[1] #得到判断元素是否需要二次定位的判断条件所在列 isSecondLocate_key=u"是否需要二次定位" SecondLocate_key_colNumber=get_number_by_data.GetRowAndColNumber().getRowAndColNumber(object_excel_path,"objname_locatemethod_locatedata",isSecondLocate_key)[1] #存储从excel表中取出的定位方式和定位数据,以及判断是否需要二次定位的条件 old_how=object_sheet.cell_value(row_index,locateMethod_colNumber) old_what=object_sheet.cell_value(row_index,locateData_colNumber) secondLocate=object_sheet.cell_value(row_index,SecondLocate_key_colNumber) locate_method_dict={'id':By.ID,'css':By.CSS_SELECTOR,'xpath':By.XPATH,'linktext':By.LINK_TEXT} if not(CommonClass().judgeSecondLocateElement(secondLocate)): if old_how=="switchHandle": index=int(old_what) CommonClass().switchHandle(br,index) else: new_how=locate_method_dict[old_how] located_element=CommonClass().findElement(br,new_how,old_what) OperateDealOrderObject.OperateDealOrderObject().operateLocatedElement(element,located_element) else: new_first_how=locate_method_dict[old_how] #得到二次定位方式的值所在列 secondLocatemethod_key=u"二次定位的方式" secondLocate_colNumber=get_number_by_data.GetRowAndColNumber().getRowAndColNumber(object_excel_path,"objname_locatemethod_locatedata",secondLocatemethod_key)[1] old_second_how=object_sheet.cell_value(row_index,secondLocate_colNumber) #得到二次定位所需值 secondLocateData_key=u"二次定位所需数据" secondLocateData_colNumber=get_number_by_data.GetRowAndColNumber().getRowAndColNumber(object_excel_path,"objname_locatemethod_locatedata",secondLocateData_key)[1] secondLocate_what=object_sheet.cell_value(row_index,secondLocateData_colNumber) new_second_how=locate_method_dict[old_second_how] second_located_element=CommonClass().locateElementIndirectly(br,new_first_how,old_what,new_second_how,secondLocate_what) OperateDealOrderObject.OperateDealOrderObject().operateLocatedElement(element,second_located_element)
def getElmentList(self): login_excel_path = r"F:\AutotestCode\Data\login_data.xls" login_sheetname = "objname_locatemethod_locatedata" sheet = ReadExcel.ReadExcel().getTableBySheetName( login_excel_path, login_sheetname) login_element_list = [] how_what_operateMethod_list = [] login_element_rows = sheet.nrows for i in range(login_element_rows): login_element_list.append(sheet.cell_value(i, 0)) login_element_list.pop(0) for element in login_element_list: how_what_operateMethod_list.append( self.getLocateMethodAndValue(login_element_list, element)) return how_what_operateMethod_list
def getElementList(self,br,testcaseId): testcase_id=testcaseId excel=ReadExcel.ReadExcel() excel_path="F:\\pytest\\xebest-autotest\\Data\\deal_order.xls" excel_sheet=excel.getTableBySheetName(excel_path,"objname_locatemethod_locatedata") rows=excel_sheet.nrows element_list=[] for i in range(1,rows): element_list.append(excel_sheet.cell_value(i,0)) for element in element_list: #调用判断元素是否操作的方法 if self.judgeElementIsOperate(element,testcase_id): #调用定位元素的方法 self.getLocateMethodAndData(br,element) else: print ("元素:%s不需要操作" %element)