TA的每日心情 | 奋斗 2020-12-11 22:39 |
---|
签到天数: 120 天 连续签到: 1 天 [LV.7]测试师长
|
class Qq():
#登陆
def user_login(self,driver,username,password):
driver.switch_to.frame("login_frame")
driver.find_element_by_xpath("//input[@name='u']").clear()
driver.find_element_by_xpath("//input[@name='u']").send_keys(username)
driver.find_element_by_xpath("//input[@name='p']").clear()
driver.find_element_by_xpath("//input[@name='p']").send_keys(password)
driver.find_element_by_id("login_button").click()
from selenium import webdriver
from qqmail import Qq
class LoginTest():
def __init__(self):
self.driver=webdriver.Ie()
self.driver.implicitly_wait(10)
self.driver.get("mail.qq.com")
#admin用户登录
def test_admin_login(self):
username='admin'
password='123'
Qq().user_login(self.driver,username,password)
self.driver.quit()
#guest用户登录
def test_guest_login(self):
username='guest'
password='321'
Qq().user_login(self.driver,username,password)
self.driver.quit()
LoginTest().test_admin_login()
LoginTest().test_guest_login()
运行后报错:
Traceback (most recent call last):
File "F:/python/qq邮箱/参数化邮箱登陆.py", line 25, in <module>
LoginTest().test_admin_login()
File "F:/python/qq邮箱/参数化邮箱登陆.py", line 15, in test_admin_login
Qq().user_login(self.driver,username,password)
File "F:/python/qq邮箱\qqmail.py", line 5, in user_login
driver.find_element_by_xpath("//input[@name='u']").clear()
File "C:\Python34\lib\site-packages\selenium\webdriver\remote\webelement.py", line 88, in clear
self._execute(Command.CLEAR_ELEMENT)
File "C:\Python34\lib\site-packages\selenium\webdriver\remote\webelement.py", line 457, in _execute
return self._parent.execute(command, params)
File "C:\Python34\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 233, in execute
self.error_handler.check_response(response)
File "C:\Python34\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 194, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.InvalidElementStateException: Message: Element must not be hidden, disabled or read-only
|
|