admin管理员组

文章数量:1532656

2024年2月8日发(作者:)

from import Byfrom ions import NoSuchElementExceptionfrom ions import TimeoutExceptionimport unittestimport HtmlTestRunnerimport sysreload(sys)aultencoding('utf-8')# 1. 打开浏览器,访问er = ()def openDriver():("")ze_window()# 2. 登陆class loginClass(object):"""docstring for login"""def __init__(self, arg):_pwd = argdef login(self):waitandSendkeys('//*[@id="Pwd"]', _pwd)waitandClick('//*[@id="Save"]')def login(data):openDriver()test1 = loginClass(data)()# 3.修改管理员密码class changePwdClass(object):"""docstring for changePwdClass"""def __init__(self, arg): = ('pwdNew', '') = ('pwdOld', '')def changeUserPwd(self):waitandClick('//*[@id="Con"]/div[1]/ul[2]/li[1]')waitandClick('//*[@id="Con"]/div[1]/ul[2]/li[1]/ul/li[3]')

]def commonAction(self, arg):error = checkData(arg)changeUserPwd_main(arg)Equal(checkResponse(error), errTips[error])(1)def test_oldPwdErr(self):Action([0])def test_lenErr(self):Action([1])def test_charErr(self):Action([2])def test_pwdSameErr(self):Action([3])def test_oldPwdBlank(self):Action([4])def test_newPwdBlank(self):Action([5])# 10. 关闭浏览器def closeDriver():(3)()('killall chromedriver')('killall geckodriver')# 11. 异常处理## 11.1 点击函数def waitandClick(xpath):try:WebDriverWait(driver, 10).until(t_to_be_clickable((, xpath)))except TimeoutException as e:print('Error:waitandClick, TimeoutException, xpath = %sn' % xpath)else:_element_by_xpath(xpath).click()## 11.2 填写表单

(testRunner=stRunner(output='test_report',report_title='修改管理员密码试报告'))closeDriver()

本文标签: 脚本浏览器管理员密码