def definelogin(self, num, login_id, confirm_ele_find, confirm_ele_find_value, click_confirm_delay_time): self.activebrowser.outPutMyLog("开始正式执行测试用例") #文本输入框添加内容 inputtext_list = inputtapinputtext.inputtapinputtext( self.activebrowser, login_id) #点击登录按钮 self.activebrowser.findEleAndClickConfigDelayTime( num, confirm_ele_find, confirm_ele_find_value, click_confirm_delay_time) self.activebrowser.getPageSource() print("已经点击确定按钮") # self.activebrowser.delayTime(30000) #验证验证文本信息 asserttest_list_all = asserttiptext.assertiptext( self.activebrowser, login_id) asserttest_list_all_long = len(asserttest_list_all) for i in range(0, asserttest_list_all_long): self.assertTrue(asserttest_list_all[i][0], asserttest_list_all[i][1]) if asserttest_list_all_long == 0: self.activebrowser.outPutErrorMyLog("【异常提示】:本用例为验证点击登录按钮后的提示信息," "但没有添加要验证的提示信息," "请检查用例测试数据,将测试数据补充完整!") self.assertTrue(False)
def definenewadd(self, num, depend_click_case_id, is_cancel, addnew_id, confirm_ele_find, confirm_ele_find_value, click_confirm_delay_time, cancel_ele_find, cancel_ele_find_value, is_submit_success, is_signel_page, page_number_xpath, result_table_ele_find, result_table_ele_find_value, table_colnum_counts ): # 如果有依赖ID,则执行依赖函数,达到执行当前用例的前提条件 if depend_click_case_id != None: print("depend_click_case_id:%s" % depend_click_case_id) self.definedepend(depend_click_case_id) self.activebrowser.outPutMyLog("依赖函数执行完毕!!!") self.activebrowser.outPutMyLog("开始正式执行测试用例") # 文本输入框添加内容 inputtext_list = inputtapinputtext.inputtapinputtext(self.activebrowser, addnew_id) # 文件输入框添加内容 inputtapinputfile.inputtapinputfile(self.activebrowser, addnew_id) # 选项框添加内容 selecttapselectoption.selecttapselectoption(self.activebrowser, addnew_id) # 单选项与复选项添加内容 radioandreelectionlabel.radioandreelectionlabel(self.activebrowser, addnew_id) # 日期添加内容 inputtapinputdatetime.inputtapinputdatetime(self.activebrowser, addnew_id) #富文本添加内容 iframe_inputtext_list = iframebodyinputtext.iframebodyinputtext(self.activebrowser, addnew_id) # 判断是否点击取消按钮 if is_cancel: # 如果点击取消按钮,则点击取消按钮 self.activebrowser.findEleAndClick(num, cancel_ele_find, cancel_ele_find_value) self.activebrowser.outPutMyLog("点击【取消】按钮") #判断取消按钮不存在 self.activebrowser.assertEleNotExist(cancel_ele_find, cancel_ele_find_value) if is_signel_page: self.activebrowser.outPutMyLog("页面不需要分页") else: son_ele_s = self.activebrowser.getFatherSonElesList("xpath", page_number_xpath, "tag_name", "li") son_count = len(son_ele_s) son_last_xpath = "%s/%s[%s]" % (page_number_xpath, "li", son_count) self.activebrowser.findEleAndClick(num, "xpath", son_last_xpath) inputtext_list_len = len(inputtext_list) for i in range(0, inputtext_list_len): reault_check = self.activebrowser. \ findEleAndCheckTableWithColnumCounts(num, result_table_ele_find, result_table_ele_find_value, inputtext_list[i], table_colnum_counts) self.assertFalse(reault_check) asserttest_list_all = asserttiptext.assertiptext(self.activebrowser, addnew_id) asserttest_list_all_long = len(asserttest_list_all) if asserttest_list_all_long == 0 and inputtext_list_len == 0: self.activebrowser.outPutErrorMyLog("【异常提示】:本用例为验证点击取消按钮的用例," "但没有添加要输入的测试数据或者验证文本信息," "请检查用例测试数据,将测试数据补充完整!") self.assertTrue(False) else: # 否则点击确定按钮 # self.activebrowser.findEleAndClick(num,confirm_ele_find,confirm_ele_find_value) self.activebrowser.findEleAndClickConfigDelayTime(num, confirm_ele_find, confirm_ele_find_value, click_confirm_delay_time) self.activebrowser.outPutMyLog("点击【确定】按钮") self.activebrowser.getPageSource() self.activebrowser.delayTime(30000) if not is_submit_success: # 如果不是添加成功,需要验证某些文本信息 self.activebrowser.outPutMyLog("提交不成功时的提示信息验证") asserttest_list_all = asserttiptext.assertiptext(self.activebrowser, addnew_id) asserttest_list_all_long = len(asserttest_list_all) if asserttest_list_all_long != 0: for i in range(0, asserttest_list_all_long): self.assertEqual(asserttest_list_all[i][0], asserttest_list_all[i][1]) else: self.activebrowser.outPutErrorMyLog("【异常提示】:本用例为验证提示信息用例," "但是却没有添加相应的提示信息测试数据" "请检查用例测试数据,将测试数据补充完整!") self.assertTrue(False) else: self.activebrowser.outPutMyLog("添加成功后的添加数据的验证") # 判断确定按钮不存在 self.activebrowser.assertEleNotExist(confirm_ele_find, confirm_ele_find_value) # 验证弹框或文本信息 asserttest_list_all = asserttiptext.assertiptext(self.activebrowser, addnew_id) asserttest_list_all_long = len(asserttest_list_all) if asserttest_list_all_long != 0: for i in range(0, asserttest_list_all_long): self.assertEqual(asserttest_list_all[i][0], asserttest_list_all[i][1]) # 是否单页面判断 if is_signel_page: self.activebrowser.outPutMyLog("页面不需要分页") else: son_ele_s = self.activebrowser.getFatherSonElesList("xpath", page_number_xpath, "tag_name", "li") son_count = len(son_ele_s) son_last_xpath = "%s/%s[%s]" % (page_number_xpath, "li", son_count) self.activebrowser.findEleAndClick(num, "xpath", son_last_xpath) # 验证表格内容 inputtext_list_len = len(inputtext_list) iframe_inputtext_list_len = len(iframe_inputtext_list) if inputtext_list_len != 0: for i in range(0, inputtext_list_len): reault_check = self.activebrowser. \ findEleAndCheckTableWithColnumCounts(num, result_table_ele_find, result_table_ele_find_value, inputtext_list[i], table_colnum_counts) self.assertTrue(reault_check) if iframe_inputtext_list_len != 0: for i in range(0, iframe_inputtext_list_len): reault_check = self.activebrowser. \ findEleAndCheckTableWithColnumCounts(num, result_table_ele_find, result_table_ele_find_value, iframe_inputtext_list[i], table_colnum_counts) self.assertTrue(reault_check) # 如果没有断言文本或者断言添加的内容,则 if asserttest_list_all_long == 0 and inputtext_list_len == 0 and iframe_inputtext_list_len ==0: self.activebrowser.outPutErrorMyLog("【异常提示】:本用例为验证添加成功后," "是否存在添加的数据或弹框提示或文本验证,但实际没有添加要验证的数据" "请检查用例测试数据,将测试数据补充完整!") self.assertTrue(False)