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()
版权声明:本文标题:python编写自动化挂机脚本_自动化脚本编写实例-python 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/xitong/1707391927a195185.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论