def test_confirm_password_disaccord(self): try: self.starttime = time.strftime("%Y-%m-%d %H:%M:%S") self.testcaseinfo.starttime = self.starttime self.setuppage.goto_setup() time.sleep(5) self.setuppage.click_modify_password() time.sleep(3) self.setuppage.set_original_password("1") self.setuppage.set_new_password(new_login_password()) self.setuppage.scroll_window() self.setuppage.set_confirm_password(new_login_password()) self.setuppage.click_savebutton() time.sleep(2) if self.setuppage.is_error_info1_displayed(): errorinfo = self.setuppage.get_error_info1_text() try: self.assertEqual(errorinfo, "原登录密码错误,请重新输入。") except Exception as e: self.log.error(traceback.format_exc()) self.testcaseinfo.result = "Fail" self.testcaseinfo.errorinfo = str(e) else: self.testcaseinfo.result = "Pass" else: self.testcaseinfo.result = "error" except Exception as err: self.testcaseinfo.errorinfo = str(err) self.testcaseinfo.result = "error" self.log.error(traceback.format_exc())
def test_modify_login_password(self): try: self.starttime = time.strftime("%Y-%m-%d %H:%M:%S") self.testcaseinfo.starttime = self.starttime self.setuppage.goto_setup() time.sleep(5) self.setuppage.click_modify_password() time.sleep(3) self.setuppage.set_original_password(original_login_password()) self.setuppage.set_new_password(new_login_password()) self.setuppage.scroll_window() self.setuppage.set_confirm_password(new_login_password()) self.setuppage.click_savebutton() time.sleep(20) self.setuppage.goto_setup_use_new_password() expecturl = "http://192.168.0.1/DhcpServer.html" try: self.assertEqual(self.setuppage.getCurrentUrl(), expecturl) except Exception as e: self.log.error(traceback.format_exc()) self.testcaseinfo.result = "Fail" self.testcaseinfo.errorinfo = str(e) else: self.testcaseinfo.result = "Pass" endtime = time.strftime("%Y-%m-%d %H:%M:%S") self.testcaseinfo.endtime = endtime self.testcaseinfo.secondsDuration = str(datetime.strptime(endtime, "%Y-%m-%d %H:%M:%S") \ - datetime.strptime(self.starttime, "%Y-%m-%d %H:%M:%S")) except Exception as err: self.testcaseinfo.errorinfo = str(err) self.testcaseinfo.result = "error" self.log.error(traceback.format_exc())
def tearDown(self): endtime = time.strftime("%Y-%m-%d %H:%M:%S") self.testcaseinfo.endtime = endtime self.testcaseinfo.secondsDuration = str(datetime.strptime(endtime, "%Y-%m-%d %H:%M:%S") \ - datetime.strptime(self.starttime, "%Y-%m-%d %H:%M:%S")) self.log.info([self.testcaseinfo.get_case_info()]) self.log.info("测试完成恢复登录密码") time.sleep(3) self.setuppage.click_modify_password() time.sleep(3) self.setuppage.set_original_password(new_login_password()) self.setuppage.set_new_password(original_login_password()) self.setuppage.scroll_window() self.setuppage.set_confirm_password(original_login_password()) self.setuppage.click_savebutton() time.sleep(5) self.setuppage.quit() repr = xlrd.open_workbook(self.reportfile, formatting_info=True) self.log.info(repr) newrepr = copy(repr) self.log.info(newrepr) newreprs = newrepr.get_sheet(0) tr.write_data(newreprs, self.teststarttime, int(self.row), *list(self.testcaseinfo.get_case_info())) newrepr.save(self.reportfile)