def test_setup(self, datayaml): """ 首页---设置操作测试 :param datayaml: 加载login_data登录测试数据 :return: """ log = Log() log.info("当前执行测试用例ID-> {0} ; 测试点-> {1}".format(datayaml['id'], datayaml['detail'])) # 调用登录方法 self.user_login_verify(ph, pwd) # 调用设置接口 self.setup_test(datayaml['data']['name'], datayaml['data']['sign']) po = setup(self.driver) if datayaml['screenshot'] == 'name_empty': log.info("检查点-> {0}".format(po.nick_error_hint())) self.assertEqual(po.nick_error_hint(), datayaml['check'][0]), "返回实际结果是->: {0}".format(po.nick_error_hint()) log.info("返回实际结果是->: {0}".format(po.nick_error_hint())) screenshot.insert_img(self.driver, datayaml['screenshot'] + '.jpg') self.exit_login_check() else: po.dig_check_setup() log.info("检查点-> {0}和{1}".format(po.nick_setup_success_hint(), po.sign_setup_success_hint())) self.assertEqual(po.nick_setup_success_hint(), datayaml['check'][0]), "返回实际结果是->: {0}".format( po.nick_setup_success_hint()) self.assertEqual(po.sign_setup_success_hint(), datayaml['check'][1]), "返回实际结果是->: {0}".format( po.sign_setup_success_hint()) log.info("返回实际结果是->: {0}和{1}".format(po.nick_setup_success_hint(), po.sign_setup_success_hint())) screenshot.insert_img(self.driver, datayaml['screenshot'] + '.jpg') self.exit_login_check()
def test_login(self, dataexecl): """ 登录测试 :param dataexecl: 加载login_data登录测试数据 :return: """ log = Log() log.info("当前执行测试用例ID-> {0} ; 测试点-> {1}".format(dataexecl['id'], dataexecl['phone'], dataexecl['password'])) # 调用登录方法 self.user_login_verify(dataexecl['phone'], dataexecl['password']) po = login(self.driver) if dataexecl['screenshot'] == 'phone_pawd_success': log.info("检查点-> {0}".format(po.user_login_success_hint())) self.assertEqual(po.user_login_success_hint(), dataexecl['check'], "成功登录,返回实际结果是->: {0}".format(po.user_login_success_hint())) log.info("成功登录,返回实际结果是->: {0}".format(po.user_login_success_hint())) screenshot.insert_img(self.driver, dataexecl['screenshot'] + '.jpg') log.info("-----> 开始执行退出流程操作") self.exit_login_check() po_exit = login(self.driver) log.info("检查点-> 找到{0}元素,表示退出成功!".format(po_exit.exit_login_success_hint())) self.assertEqual(po_exit.exit_login_success_hint(), '登录', "退出登录,返回实际结果是->: {0}".format(po_exit.exit_login_success_hint())) log.info("退出登录,返回实际结果是->: {0}".format(po_exit.exit_login_success_hint())) else: log.info("检查点-> {0}".format(po.phone_pawd_error_hint())) self.assertEqual(po.phone_pawd_error_hint(), dataexecl['check'], "异常登录,返回实际结果是->: {0}".format(po.phone_pawd_error_hint())) log.info("异常登录,返回实际结果是->: {0}".format(po.phone_pawd_error_hint())) screenshot.insert_img(self.driver, dataexecl['screenshot'] + '.jpg')
def test_case1(self): chromeDriver = self.driver chromeDriver.get('http://*****:*****@id="applyTableId"]/tbody/tr[1]/td[11]/a').click() sleep(1) Select( chromeDriver.find_element_by_xpath( '/html/body/div[12]/form/div[2]/div[6]/div[2]/table[2]/tbody[1]/tr[3]/td/table[1]/tbody/tr/td/table/tbody/tr[3]/td[1]/select' )).select_by_index(1) sleep(1) chromeDriver.find_element_by_xpath( '/html/body/div[12]/form/div[2]/div[6]/div[2]/table[2]/tbody[1]/tr[3]/td/table[1]/tbody/tr/td/table/tbody/tr[3]/td[2]/input[1]' ).send_keys('啦啦啦啦啦') Select( chromeDriver.find_element_by_xpath( '/html/body/div[12]/form/div[2]/div[6]/div[2]/table[2]/tbody[1]/tr[3]/td/table[1]/tbody/tr/td/table/tbody/tr[3]/td[3]/select' )).select_by_index(2) chromeDriver.find_element_by_xpath( '/html/body/div[12]/form/div[2]/div[6]/div[2]/table[2]/tbody[1]/tr[3]/td/table[1]/tbody/tr/td/table/tbody/tr[3]/td[4]/input[2]' ).send_keys('哈哈哈哈哈') Select( chromeDriver.find_element_by_xpath( '/html/body/div[12]/form/div[2]/div[6]/div[2]/table[2]/tbody[1]/tr[3]/td/table[1]/tbody/tr/td/table/tbody/tr[3]/td[5]/div/select[2]' )).select_by_index(1) sleep(1) Select( chromeDriver.find_element_by_xpath( '/html/body/div[12]/form/div[2]/div[6]/div[2]/table[2]/tbody[1]/tr[3]/td/table[1]/tbody/tr/td/table/tbody/tr[3]/td[5]/div/select[3]' )).select_by_index(1) sleep(1) Select( chromeDriver.find_element_by_xpath( '/html/body/div[12]/form/div[2]/div[6]/div[2]/table[2]/tbody[1]/tr[3]/td/table[1]/tbody/tr/td/table/tbody/tr[3]/td[5]/div/select[4]' )).select_by_index(1) sleep(1) chromeDriver.find_element_by_xpath( '/html/body/div[12]/form/div[2]/div[6]/div[2]/table[2]/tbody[1]/tr[3]/td/table[1]/tbody/tr/td/table/tbody/tr[3]/td[7]/table/tbody/tr[1]/td/a' ).click() sleep(1) chromeDriver.find_element_by_xpath( '/html/body/div[13]/div/table/tbody/tr[2]/td[2]/div[2]/div/div/table/tbody/tr[2]/td/table/tbody/tr[1]/td[3]/a' ).click() Select( chromeDriver.find_element_by_xpath( '/html/body/div[13]/div/table/tbody/tr[2]/td[2]/div[2]/div/div/table/tbody/tr[2]/td/table/tbody/tr[3]/td[1]/select' )).select_by_index(1) sleep(1) Select( chromeDriver.find_element_by_xpath( '/html/body/div[13]/div/table/tbody/tr[2]/td[2]/div[2]/div/div/table/tbody/tr[2]/td/table/tbody/tr[3]/td[2]/select' )).select_by_index(1) chromeDriver.find_element_by_xpath( '/html/body/div[13]/div/table/tbody/tr[2]/td[2]/div[2]/div/a' ).click() chromeDriver.find_element_by_xpath( '/html/body/div[12]/form/div[2]/div[6]/div[2]/table[2]/tbody[1]/tr[3]/td/table[1]/tbody/tr/td/table/tbody/tr[3]/td[8]/textarea' ).send_keys('abc') chromeDriver.find_element_by_xpath('//*[@id="SUBMIT"]/button').click() sleep(1) screenshot.insert_img(chromeDriver, '截图.png') chromeDriver.find_element_by_xpath( '/html/body/div[13]/div/table/tbody/tr[2]/td[2]/div[2]/div/div[3]/a' ).click() chromeDriver.find_element_by_id( 'S_01_01_RELEVANT_EVALUATION').send_keys('bcd') chromeDriver.find_element_by_xpath('//*[@id="SUBMIT"]/button').click() sleep(1) chromeDriver.find_element_by_xpath( '/html/body/div[13]/div/table/tbody/tr[2]/td[2]/div[2]/div/div[2]/fieldset/table/tbody/tr[1]/td[2]/textarea' ).send_keys('哈哈哈哈哈') chromeDriver.find_element_by_xpath( '/html/body/div[13]/div/table/tbody/tr[2]/td[2]/div[2]/div/div[2]/fieldset/table/tbody/tr[3]/td[2]/input[2]' ).send_keys('hudan') chromeDriver.find_element_by_xpath( '/html/body/div[13]/div/table/tbody/tr[2]/td[2]/div[2]/div/div[2]/fieldset/table/tbody/tr[4]/td[2]/input' ).send_keys('f') chromeDriver.find_element_by_xpath( '/html/body/div[13]/div/table/tbody/tr[2]/td[2]/div[2]/div/p/label/input' ).click() chromeDriver.find_element_by_xpath( '/html/body/div[13]/div/table/tbody/tr[2]/td[2]/div[2]/div/div[3]/p/input' ).click() sleep(5)