51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

查看: 2907|回复: 5
打印 上一主题 下一主题

[求助] 参数化邮箱登陆

[复制链接]
  • TA的每日心情
    奋斗
    2020-12-11 22:39
  • 签到天数: 120 天

    连续签到: 1 天

    [LV.7]测试师长

    跳转到指定楼层
    1#
    发表于 2016-6-15 00:09:27 | 显示全部楼层 回帖奖励 |倒序浏览 |阅读模式
    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


    分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
    收藏收藏
    回复

    使用道具 举报

  • TA的每日心情
    奋斗
    2020-12-11 22:39
  • 签到天数: 120 天

    连续签到: 1 天

    [LV.7]测试师长

    2#
     楼主| 发表于 2016-6-15 22:31:30 | 显示全部楼层
    掉渣饼 发表于 2016-6-15 11:50
    driver.switch_to.frame("login_frame")这个你写错了  driver.switch_to_frame("login_frame")
      self.d ...

    按照你说的方法,跑脚本还是报同样的错误,,麻烦再帮忙看一下,谢谢~
    回复 支持 反对

    使用道具 举报

    本版积分规则

    关闭

    站长推荐上一条 /1 下一条

    小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

    GMT+8, 2024-5-17 13:41 , Processed in 0.063283 second(s), 22 queries .

    Powered by Discuz! X3.2

    © 2001-2024 Comsenz Inc.

    快速回复 返回顶部 返回列表