class GetData: def __init__(self): self.opera_excel = OperaExcel() def get_case_lines(self): lines = self.opera_excel.get_lines() return lines def get_handle_step(self, row): handle_step = self.opera_excel.get_cell(row, 3) return handle_step def get_element_key(self, row): element_key = self.opera_excel.get_cell(row, 4) return element_key def get_handle_element(self, row): handle_element = self.opera_excel.get_cell(row, 5) return handle_element def get_except_element(self, row): print("hello") except_element = self.opera_excel.get_cell(row, 6) return except_element def write_value(self, row, value): self.opera_excel.write_value(row, value)
class GetData: def __init__(self): self.opera_excel = OperaExcel() def get_case_lines(self): ''' 获取case的行数 ''' lines = self.opera_excel.get_lines() return lines def get_handle_step(self, row): ''' 获取操作步骤里面的操作方法名字 ''' method_name = self.opera_excel.get_cell(row, 3) return method_name def get_element_key(self, row): ''' 获取操作元素的key ''' element_key = self.opera_excel.get_cell(row, 4) if element_key == '': return None return element_key def get_handle_value(self, row): ''' 获取操作元素的值 ''' handle_value = self.opera_excel.get_cell(row, 5) if handle_value == '': return None return handle_value def get_expect_element(self, row): ''' 获取预期结果元素element ''' expect_element = self.opera_excel.get_cell(row, 6) if expect_element == '': return None return expect_element def get_is_run(self, row): is_run = self.opera_excel.get_cell(row, 8) if is_run == 'yes': return True else: return False def get_expect_handle(self, row): expect_step = self.opera_excel.get_cell(row, 7) if expect_step == "": return None return expect_step def write_value(self, row, value): self.opera_excel.write_value(row, value)
def run_main(self): user = UserLog() log = user.get_log() log.debug('debug-test') #log.info('keyword_case') self.action_method = actionMethod() handle_excel = OperaExcel( 'C:/Users/xx/Desktop/SeleniumPython2/config/keyword.xls', 0) case_lines = handle_excel.get_lines() if case_lines: for i in range(1, case_lines): #is_run是否执行 is_run = handle_excel.get_cell(i, 3) if is_run == 'yes': #method:执行方法;send_value:输入的数据;handle_value:操作元素 method = handle_excel.get_cell(i, 4) send_value = handle_excel.get_cell(i, 5) handle_element = handle_excel.get_cell(i, 6) except_result_method = handle_excel.get_cell(i, 7) except_result = handle_excel.get_cell(i, 8) self.run_method(method, handle_element, send_value) if except_result != '': #将预期结果值根据=划分成list except_value = self.get_except_result_value( except_result) if except_value[0] == 'text': result = self.run_method(except_result_method, handle_element, '') if except_value[1] in result: handle_excel.write_value(i, 'pass') else: handle_excel.write_value(i, 'fail') elif except_value[0] == 'element': result = self.run_method(except_result_method, except_value[1], '') if result != 'error': handle_excel.write_value(i, 'pass') else: handle_excel.write_value(i, 'fail') else: print('没有else') else: print('没有预期结果')
class ConfigData: def __init__(self,filename="../config/case_key.xls"): self.op = OperaExcel(filename) def get_case_id(self,row): value = self.op.get_value(row,0) if value == '': return None else: return value def get_case_name(self,row): value = self.op.get_value(row,1) if value == '': return None else: return value def get_opera_desc(self,row): value = self.op.get_value(row,2) if value == '': return None else: return value def get_opera_method(self,row): value = self.op.get_value(row,3) if value == '': return None else: return value def get_opera_element_key(self,row): value = self.op.get_value(row,4) if value == '': return None else: return value def get_opera_data(self,row): value = self.op.get_value(row,5) if value == '': return None else: return value def get_expect_element(self,row): value = self.op.get_value(row,6) if value == '': return None else: return value def get_expect_method(self,row): value = self.op.get_value(row, 7) if value == '': return None else: return value def get_expect_result(self,row): value = self.op.get_value(row,8) if value == '': return None else: return value def write_real_result(self,row,value): self.op.write_value(row,9,value) def get_lines(self): return self.op.get_rows_num() def get_is_run(self,row): value = self.op.get_value(row, 10) if value == '': return None else: return value