zoukankan      html  css  js  c++  java
  • 【Selenium】【BugList8】126邮箱定位不到“退出”按钮:Message: TypeError: can't access dead object

    【流程描述】

    登录126邮箱,退出

    【代码】

    #coding=utf-8
    from selenium import webdriver
    
    driver = webdriver.Firefox()
    #driver = webdriver.Ie()
    driver.implicitly_wait(10)
    driver.get("https://mail.126.com/")
    
    #切换到frame
    driver.switch_to.frame("x-URS-iframe")
    #输入密码、用户名,登录
    
    driver.find_element_by_name("password").clear()
    driver.find_element_by_name("password").send_keys("xxx")
    driver.find_element_by_name("email").clear()
    driver.find_element_by_name("email").send_keys("yyy")
    
    driver.find_element_by_id("dologin").click()
    
    #退出
    driver.find_element_by_xpath("/html/body/header/div[1]/ul[1]/li[16]/a").click()
    driver.quit()
    

    【报错】

    ====================== RESTART: F:/PySouce/mail1261.py ======================
    Traceback (most recent call last):
    File "F:/PySouce/mail1261.py", line 26, in <module>
    driver.find_element_by_xpath("/html/body/header/div[1]/ul[1]/li[16]/a").click()
    File "D:Program Filespython36libsite-packagesseleniumwebdriver emotewebdriver.py", line 385, in find_element_by_xpath
    return self.find_element(by=By.XPATH, value=xpath)
    File "D:Program Filespython36libsite-packagesseleniumwebdriver emotewebdriver.py", line 955, in find_element
    'value': value})['value']
    File "D:Program Filespython36libsite-packagesseleniumwebdriver emotewebdriver.py", line 312, in execute
    self.error_handler.check_response(response)
    File "D:Program Filespython36libsite-packagesseleniumwebdriver emoteerrorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
    selenium.common.exceptions.WebDriverException: Message: TypeError: can't access dead object

    【解决方法】

    #coding=utf-8
    from selenium import webdriver
    
    driver = webdriver.Firefox()
    #driver = webdriver.Ie()
    driver.implicitly_wait(10)
    driver.get("https://mail.126.com/")
    
    #切换到frame
    driver.switch_to.frame("x-URS-iframe")
    #输入密码、用户名,登录
    
    driver.find_element_by_name("password").clear()
    driver.find_element_by_name("password").send_keys("xxx")
    driver.find_element_by_name("email").clear()
    driver.find_element_by_name("email").send_keys("yyy")
    
    driver.find_element_by_id("dologin").click()
    
    #切换到主文档
    driver.switch_to.default_content()
    driver.implicitly_wait(10)
    #退出
    driver.find_element_by_xpath("/html/body/header/div[1]/ul[1]/li[16]/a").click()
    driver.quit()

    【Ending】

    微信公众号“粒粒的测试笔记

      

  • 相关阅读:
    极速南瓜(北京)品牌管理顾问有限公司
    许涛芳_百度百科
    个性化品牌开始繁荣?为设计师和代工厂牵线的平台Maker's Row获得100万美元融资 | 36氪
    薛蟠_百度百科
    莫龙丹_百度百科
    尊履·尚品|手工鞋|固特异|定制鞋
    联系我们_你我想法_【有男度】UNANDU 100%进口 全球设计师品牌精汇 男装_男装搭配_时尚男装_品牌男装_男装搭配技巧_男装网站
    全球高级定制鞋完全指南
    百年定制老字号落户扬城 服装“私人定制”悄然兴起
    享受私人定制服装(下)
  • 原文地址:https://www.cnblogs.com/yllil/p/9579617.html
Copyright © 2011-2022 走看看