def run_keyword_excel_cases(self): handle_excel = ReadExcel(self.excel_path) # 获取 excel 关键词测试用例的条数 cases_numbers = handle_excel.get_lines() - 1 print("注册页获取到的关键词测试的测试用例条数为:%s" % cases_numbers) # 循环遍历测试用例 if cases_numbers: # 第 0 行是标题行不作为用例执行 for i in range(1, cases_numbers): # 获取测试用例的名称 testcase_name = handle_excel.get_cell(i, 0) # 获取用例是否执行 is_run = handle_excel.get_cell(i, 1) if is_run == 'yes': keyword_method = handle_excel.get_cell(i, 2) operator_element = handle_excel.get_cell(i, 3) send_value = handle_excel.get_cell(i, 4) except_result = handle_excel.get_cell(i, 5) actual_result = handle_excel.get_cell(i, 6) # 反射 self.run_keyword_method(keyword_method, operator_element, send_value) # if except_result is not '': # except_value = self.run_keyword_method(keyword_method) else: print('第 %s 条用例不执行,用例名称是: [%s],无预期结果' % (i, testcase_name)) else: print("略略略~,请检查你是否有写测试用例!")
def run_main(self): self.action_m = ActionMethod() read_e = ReadExcel() case_lines = read_e.get_lines() is_run_col = 3 if case_lines: for i in range(1,case_lines): read_e.write_value(i,10,"test") # continue handle_name = read_e.get_cell(i,2) print(handle_name+": ") is_run = read_e.get_cell(i,is_run_col) print(is_run) if is_run == "yes": method = read_e.get_cell(i,4) send_value = read_e.get_cell(i,5) handle_value = read_e.get_cell(i,6) except_result_method = read_e.get_cell(i,7) except_result = read_e.get_cell(i,8) self.run_method(method,send_value,handle_value) if except_result != '': except_value = self.get_excel_result_value(except_result) if except_value[0] == 'text': result = self.run_method(except_result_method) if except_value[1] in result: read_e.write_value(i,9,"pass") else: read_e.write_value(i,9,"fail") elif except_value[0] == 'element': print("except_value[1]:") print(except_value[1]) print("except_result:") print(except_result_method) result = self.run_method(except_result_method,except_value[1]) if result: read_e.write_value(i,9,"pass") else: read_e.write_value(i,9,"fail") else: print("没有else") else: print("预期结果为空")
def run_main(self): self.action_method = ActionMethod() # print(self.action_method) handle_excel = ReadExcel('../config/test_case.xls') case_lines = handle_excel.get_lines() if case_lines: for i in range(1, case_lines): is_run = handle_excel.get_cell(i, 3) # r如果方法执行为yes if is_run == 'yes': method = handle_excel.get_cell(i, 4) input_data = handle_excel.get_cell(i, 5) handle_element = handle_excel.get_cell(i, 6) expect_result_method = handle_excel.get_cell(i, 7) expect_result = handle_excel.get_cell(i, 8) self.run_method(method, input_data, handle_element) # 预期结果不等于空 if expect_result != '': except_result_value = self.get_expect_result( expect_result) # 获取页面title if except_result_value[0] == 'text': result = self.run_method(expect_result_method) if except_result_value[1] in result: handle_excel.write_value(i, 9, 'pass') else: handle_excel.write_value(i, 9, 'fail') elif except_result_value[0] == 'element': result = self.run_method(expect_result_method, except_result_value[1]) if result: handle_excel.write_value(i, 9, 'pass') else: handle_excel.write_value(i, 9, 'fail') else: print('除了text和element之外的') else: print('预期结果为空')