def search_stu_info(self, info): self.into_stu_manage() Service.into_module(self.driver, '学员信息') self.input_value(info['name']) self.driver.find_element_by_xpath( "//button[@class='btn btn-info btn-padding']").click() time.sleep(1)
def edit_name(self, editname): ed_name = self.driver.find_element_by_xpath( '//*[@id="modLeave-form"]/div[3]/div[1]/input') Service.send_input(ed_name, editname) clcik_text = self.driver.find_element_by_xpath( '//*[@id="modLeave-form"]/div[4]/div/textarea') clcik_text.click()
def click_module_name(self): Service.open_page(self.driver) info = [ 'WNCD051', 'Woniu123', 'Woniu123', '/html/body/div[4]/div[2]/div[8]/div[1]/a', '//*[@id="list-31"]/div/ul/li[3]/a' ] Service.open_module_connect(self.driver, info)
def search_evaluate(self, info): self.into_stu_manage() Service.into_module(self.driver, '日常考评') #找到姓名输入框,输入 name = self.driver.find_element_by_xpath( "/html/body/div[8]/div[2]/div/div/div/div[1]/input") Service.send_input(name, info['name']) self.driver.find_element_by_xpath( "//button[@class='btn btn-info btn-padding']").click()
def setUp(self): self.driver = Service.get_driver() Service.open_page(self.driver) info = [ 'WNCD051', 'Woniu123', 'Woniu123', '/html/body/div[4]/div[2]/div[8]/div[1]/a', '//*[@id="list-31"]/div/ul/li[3]/a' ] Service.open_module_connect_zz(self.driver, info)
def setUp(self): # 获取绕过登录的信息 login_ele = Util.get_json( "..\\..\\conf\\ResourceAdministration_Conf\\RA_Login.conf")[1] self.driver = Service.get_driver() Service.open_page(self.driver) Service.open_module_connect(self.driver, login_ele) self.ele = Util.get_json( "..\\..\\conf\\ResourceAdministration_Conf\\RA_Element.conf")
def setUp(self): self.driver = Service.get_driver() Service.open_page(self.driver) info = [ 'WNCD000', 'woniu123', 'woniu123', '//*[@id="nav2"]/div[7]/div[1]/a', '//*[@id="list-11"]/div/ul/li[1]/a' ] Service.open_module_connect_zz(self.driver, info)
def stu_name(self, sname): s_name = self.driver.find_element_by_xpath( '//*[@id="leave-form"]/div[3]/div/input') Service.send_input(s_name, sname) # s_info = self.driver.find_element_by_xpath\ # ('//*[@id="leave-form"]/div[3]/div/ul/li/a') # s_info.click() clcik_text = self.driver.find_element_by_xpath( '//*[@id="leave-form"]/div[4]/div/textarea') clcik_text.click()
def test_alter_TR(self,*alter_info): print(alter_info) TR_Action(self.driver).do_alter(alter_info[:-1]) self.driver.refresh() Service.input_motion(self.driver,"xpath","//*[@id='content']/div[2]/div/input[3]", alter_info[1]) Service.click_motion(self.driver,"xpath","//*[@id='content']/div[2]/div/button") msg = Service.get_hint(self.driver,'//*[@id="content"]/div[3]/div/div[1]/div[2]/div[4]/div[1]/span[1]') if "总共 1 条记录" in msg: actual = "alter_pass" else: actual = "alter_fail" self.assertEqual(actual, alter_info[-1])
def test_query_CR(self, *query_info): msg_xpath = '//*[@id="content"]/div[3]/div/div[1]/div[2]/div[4]/div[1]/span[1]' time.sleep(2) Service.click_motion(self.driver, 'xpath', self.ele[7]["CR_commonality_xpath"]) #执行测试动作 CR_Action(self.driver).do_query(query_info[:-1]) #获取列表信息,并提取总数 msg = Service.get_hint(self.driver, msg_xpath) if len(msg) >= 1: actual = "query_pass" else: actual = "query_fail" self.assertEqual(actual, query_info[-1])
def do_login(self, username, userpass): Service.input_motion(self.driver, "name", self.ele[0]["username_name"], username) Service.input_motion(self.driver, "name", self.ele[0]["userpass_name"], userpass) Service.click_motion(self.driver, "xpath", self.ele[0]["blank_xpath"]) Service.click_motion(self.driver, "xpath", self.ele[0]["login_xpath"])
def test_tail_TR(self,*tail_info): #获取返回的电话 phone = TR_Action(self.driver).do_tail(tail_info[:-1]) self.driver.refresh() #输入电话并查询 Service.input_motion(self.driver,"xpath",self.ele[3]["TR_condition_xpath"],phone) Service.click_motion(self.driver,'xpath', self.ele[0]["TR_search_xpath"]) #获取查询出来的学员信息的状态 time.sleep(1) status = self.driver.find_element_by_xpath('//*[@id="personal-table"]/tbody/tr[1]/td[5]').text if tail_info[1] == status: actual = "tail_pass" else: actual = "tail_fail" self.assertEqual(actual, tail_info[-1])
def click_random_inter_button(self): number = Service.random_delete( self.driver, '//*[@id="skills"]/div[2]/div[2]/div[4]/div[1]/span[1]') self.driver.find_element_by_xpath( f'//*[@id="stuInfo_table"]/tbody/tr[{number}]/td[9]/button').click( )
def add_resource(self, resource_info): self.into_resource() self.driver.find_element_by_xpath( '/html/body/div[8]/div[2]/div[2]/button[4]').click() self.input_phone(resource_info['phone']) self.input_name(resource_info['name']) self.input_age(resource_info['age']) self.input_area(resource_info['area']) self.input_partment(resource_info['partment']) self.input_education(resource_info['education']) self.input_eduexp(resource_info['eduexp']) self.input_experience(resource_info['experience']) self.input_sex(resource_info['sex']) self.input_school(resource_info['school']) self.input_source(resource_info['source']) self.input_status(resource_info['status']) self.input_workage(resource_info['workage']) self.input_wx(resource_info['wx']) self.input_qq(resource_info['qq']) self.input_major(resource_info['major']) self.driver.find_element_by_id('addCusBtn').click() if Service.is_element_present( self.driver, 'xpath', '/html/body/div[12]/div/div/div[3]/button'): return True else: return False
def do_claim(self): Service.click_motion(self.driver, 'xpath', self.ele[6]["CR_query_xpath"]) num = Service.random_delete(self.driver, self.ele[0]["TR_student_list_xpath"]) Service.click_motion( self.driver, 'xpath', f'//*[@id="public-pool-table"]/tbody/tr[{num}]/td[1]/input') time.sleep(1) Service.click_motion(self.driver, 'xpath', self.ele[7]["CR_claim_xpath"]) Service.click_motion(self.driver, 'xpath', self.ele[7]["CR_confirm_claim_xpath"])
def test_login(self, username, userpass, expect): L_Action(self.driver).do_login(username, userpass) if Service.is_element_present(self.driver, "xpath", "/html/body/div[2]/div[2]/ul/li[2]/a"): actual = "login_pass" else: actual = "login_fail" self.assertEqual(actual, expect)
def test_add_week_grade(self,stage,grade,expect): grade_info = {'stage':stage,'grade':grade,'expect':expect} Student_Manage(self.driver).add_week_grade(grade_info ) if Service.is_element_present(self.driver,'xpath',"//div[@class='bootbox-body']") == True: actual = 'add-fail' else: actual = 'add-success' self.assertEqual(actual, expect)
def test_interview(self,*interview_info): Tech(self.driver).do_interview(interview_info[:-1]) msg = Service.get_hint(self.driver,'/html/body/div[10]/div/div/div[2]/div') if "保存成功" in msg: actual = "interview_pass" else: actual = "interview_fail" self.assertEqual(actual,interview_info[-1])
def test_search(self,*sous_info):#*不定长参数 Tech(self.driver).do_search(sous_info[:-1]) Tech(self.driver).click_search_button() msg = Service.get_hint(self.driver,"/html/body/div[8]/div[2]/div/div/div/div/div[2]/div[2]/div[4]/div[1]/span[1]") if len(msg) >= 1: actual = "search_pass" else: actual = "search_fail" self.assertEqual(actual,sous_info[-1])
def test_course(self, *cour_info): #*不定长参数 C_Action(self.driver).do_course(cour_info[:-1]) msg1 = Service.get_hint(self.driver, '/html/body/div[16]/div/div/div[2]/div') if '排课成功' in msg1: actual = "cour_pass" else: actual = "cour_fail" self.assertEqual(actual, cour_info[-1])
def upload_resource(self, info): self.into_resource() self.driver.find_element_by_xpath( "/html/body/div[8]/div[2]/div[2]/button[3]").click() #点击上传按钮 area = self.driver.find_element_by_xpath( "//select[@id='regionSelect']") #区域下拉框 Service.droplist(area, info['area']) partment = self.driver.find_element_by_xpath( "//select[@id='dpetSelect']") #部门下拉框 Service.droplist(partment, info['partment']) self.driver.find_element_by_xpath('//*[@id="files"]').send_keys( info['path']) #传入文件路径 self.driver.find_element_by_xpath( "//div[@class='modal-footer']/button[@class='btn btn-primary btn-padding']" ).click() msg = self.driver.find_element_by_xpath( "//div[@class='bootbox-body']").get_attribute("innerHTML") return msg
def test_query_DR(self, *query_info): msg_xpath = '//*[@id="content"]/div[3]/div/div[1]/div[2]/div[4]/div[1]/span[1]' # 执行测试动作 DR_Action(self.driver).do_query(query_info[:-1]) # 获取列表信息,并提取总数 msg = Service.get_hint(self.driver, msg_xpath) if len(msg) >= 1: actual = "query_pass" else: actual = "query_fail" self.assertEqual(actual, query_info[-1])
def test_query(self, *query_info): #*不定长参数 C_Action(self.driver).do_query(query_info[:-1]) #C_Action(self.driver).click_query_button() msg = Service.get_hint( self.driver, '//*[@id="course"]/div[2]/div[2]/div[4]/div[1]/span[1]') if len(msg) >= 1: actual = "query_pass" else: actual = "query_fail" self.assertEqual(actual, query_info[-1])
def search_resource(self, info): self.into_resource() self.input_value(info['value']) self.driver.find_element_by_xpath( '/html/body/div[8]/div[2]/div[2]/button[1]').click() if Service.is_element_present( self.driver, 'xpath', "//td[12]/button[@class='btn btn-info']") == True: return True else: return False
def do_delete(self): num = Service.random_delete(self.driver, self.ele[0]["TR_student_list_xpath"]) Service.click_motion( self.driver, "xpath", f"//*[@id='personal-table']/tbody/tr[{num}]/td[1]/input") Service.click_motion(self.driver, 'xpath', self.ele[2]["TR_abandon_xpath"]) self.driver.execute_script('window.scrollBy(0,-100)') time.sleep(1) Service.click_motion(self.driver, 'xpath', self.ele[2]["TR_confirm_abandon_xpath"])
def search_week_grade(self, info): self.into_stu_manage() Service.into_module(self.driver, '周考成绩') #选择区域 area = self.driver.find_element_by_xpath( "//select[@class='sel-text'][1]") Service.droplist(area, info['area']) #选择班级 classes = self.driver.find_element_by_xpath( "//select[@class='sel-text'][2]") Service.droplist(classes, info['classes']) #输入姓名 name = self.driver.find_element_by_xpath( "//div[2]/div/div/div/div[1]/input") Service.send_input(name, info['name']) #点击查询 self.driver.find_element_by_xpath( "//div[2]/div/div/div/div[1]/button").click()
def test_deliver_DR(self, *deliver_info): msg_xpath = '//*[@id="content"]/div[3]/div/div[1]/div[2]/div[4]/div[1]/span[1]' Service.click_motion(self.driver, 'xpath', self.ele[8]["DR_query_xpath"]) old_msg = Service.get_hint(self.driver, msg_xpath) DR_Action(self.driver).do_deliver(deliver_info[:-1]) self.driver.refresh() Service.click_motion(self.driver, 'xpath', self.ele[8]["DR_query_xpath"]) new_msg = Service.get_hint(self.driver, msg_xpath) if old_msg != new_msg: actual = "deliver_pass" else: actual = "deliver_fail" self.assertEqual(actual, deliver_info[-1])
def test_add_TR(self,*add_info): msg_xpath = '//*[@id="content"]/div[3]/div/div[1]/div[2]/div[4]/div[1]/span[1]' #第一次默认查询,获取数据总条数 Service.click_motion(self.driver,'xpath',self.ele[0]["TR_search_xpath"]) old_msg = Service.get_hint(self.driver,msg_xpath) #完成新增 TR_Action(self.driver).do_add(add_info[:-1]) self.driver.refresh() #第二次默认查询,获取数据总条数 Service.click_motion(self.driver,'xpath',self.ele[0]["TR_search_xpath"]) new_msg = Service.get_hint(self.driver,msg_xpath) if old_msg != new_msg: actual = "add_pass" else: actual = "add_fail" self.assertEqual(actual, add_info[-1])
def test_delete_TR(self): expect = "delete_pass" msg_xpath = '//*[@id="content"]/div[3]/div/div[1]/div[2]/div[4]/div[1]/span[1]' # 第一次默认查询,获取数据总条数 Service.click_motion(self.driver,'xpath',self.ele[0]["TR_search_xpath"]) old_msg = Service.get_hint(self.driver, msg_xpath) #完成删除 TR_Action(self.driver).do_delete() self.driver.refresh() # 第二次默认查询,获取数据总条数 Service.click_motion(self.driver,'xpath',self.ele[0]["TR_search_xpath"]) new_msg = Service.get_hint(self.driver, msg_xpath) if old_msg != new_msg: actual = "delete_pass" else: actual = "delete_fail" self.assertEqual(actual, expect)
def alter_stu_info(self, info): self.into_stu_manage() Service.into_module(self.driver, '学员信息') #先点击查询 self.driver.find_element_by_xpath( "//button[@class='btn btn-info btn-padding']").click() time.sleep(1) xpath = "//span[@class='pagination-info']" num = Service.random_delete(self.driver, xpath) #点击随机到的资源修改按钮 self.driver.find_element_by_xpath( f"//tr[{num}]/td[12]/button[@class='btn btn-info'][2]").click() time.sleep(1) #修改电话 phone = self.driver.find_element_by_name("stu.tel") Service.send_input(phone, info['phone']) #修改状态 status = self.driver.find_element_by_name("stu.status") Service.droplist(status, info['status']) self.driver.find_element_by_xpath( "//div[@class='modal-content']/div[@class='modal-footer']/button[@class='btn btn-primary btn-save']" ).click()