Python webdriver error WebDriverException:Message:can ' t access dead object Reason (in Pycharm)

Source: Internet
Author: User
Tags xpath

Pycharm running Firefox webdriver access to the mailbox when adding address Book error-WebDriverException:Message:can ' t access dead object

Adjusted for a long time, found that because the login operation has not been changed from the frame, because in the log on the need to switch to the frame, after login to switch out to continue other operations.

Here is the code I ran, driver.switch_to.default_content () This line was commented out by me, the result is to report this error


Code:
Driver=webdriver. Firefox (executable_path= ' c:\\geckodriver ')
Driver.get (' http://mail.126.com ')
Try
Wait=webdriverwait (driver,10,0.2) #显示等待
Driver.switch_to.frame (Driver.find_element_by_xpath ("//iframe[@id = ' x-urs-iframe ')") #切换到用户名和密码输入框所在的frame元素

Name=wait.until (Lambda x:x.find_element_by_xpath ("//input[@placeholder = ' mailbox account or phone number ' and @name = ' email ')])
Name.send_keys (' xiaxiaoxu1987 ')
Password=wait.until (Lambda x:x.find_element_by_xpath ("//input[@placeholder = ' password ')")
Password.send_keys (' Gloryroad ')
Submit=wait.until (Lambda x:x.find_element_by_xpath ("//a[@id = ' dologin ')")
Submit.click ()
#driver. Switch_to.default_content () #在pycharm里用switch_to_default_content () will be added strikethrough, out of the

Address_book_link=wait.until (Lambda X:x.find_element_by_xpath ("//div[text () = ' Address Book ']")
Address_book_link.click ()


Operation Error:

C:\Python27\python.exe d:/test/datadriventestpractice1/pageobject/test.py
Traceback (most recent):
File "d:/test/datadriventestpractice1/pageobject/test.py", line +, in <module>
Address_book_link=wait.until (Lambda X:x.find_element_by_xpath ("//div[text () = ' Address Book ']")
File "C:\Python27\lib\site-packages\selenium\webdriver\support\wait.py", line +, in until
Value = Method (Self._driver)
File "d:/test/datadriventestpractice1/pageobject/test.py", line +, in <lambda>
Address_book_link=wait.until (Lambda X:x.find_element_by_xpath ("//div[text () = ' Address Book ']")
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 387, in Find_element_by_xpath
Return Self.find_element (By=by.xpath, Value=xpath)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 957, in Find_element
' Value ': value}) [' Value ']
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 314, in Execute
None
Self.error_handler.check_response (response)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in Check_response
Raise Exception_class (message, screen, stacktrace)
WebDriverException:Message:can ' t access dead object


Process finished with exit code 0

Remove the comment:

Driver=webdriver. Firefox (executable_path= ' c:\\geckodriver ')
Driver.get (' http://mail.126.com ')
Try
Wait=webdriverwait (driver,10,0.2) #显示等待
Driver.switch_to.frame (Driver.find_element_by_xpath ("//iframe[@id = ' x-urs-iframe ')") #切换到用户名和密码输入框所在的frame元素

Name=wait.until (Lambda x:x.find_element_by_xpath ("//input[@placeholder = ' mailbox account or phone number ' and @name = ' email ')])
Name.send_keys (' xiaxiaoxu1987 ')
Password=wait.until (Lambda x:x.find_element_by_xpath ("//input[@placeholder = ' password ')")
Password.send_keys (' Gloryroad ')
Submit=wait.until (Lambda x:x.find_element_by_xpath ("//a[@id = ' dologin ')")
Submit.click ()
driver.switch_to.default_content () #在pycharm里用switch_to_default_content () will be added strikethrough, out of

Address_book_link=wait.until (Lambda X:x.find_element_by_xpath ("//div[text () = ' Address Book ']")
Address_book_link.click ()

Result: no error

C:\Python27\python.exe d:/test/datadriventestpractice1/pageobject/test.py

Process finished with exit code 0

Python webdriver error WebDriverException:Message:can ' t access dead object Reason (in Pycharm)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.