Python+selenium frequently asked questions how to solve

Source: Internet
Author: User

1, can not start the browser, error is as follows:

============================= ERRORS =============================
Traceback (most recent):
File "D:\python_files\eclipse_wrokstation\WinshareWebAotuTest\TestCase\testBookComments.py", line +, in SetUp
Self.driver = Webdriver. Chrome ()
File "D:\Program files\python\python3\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line page, in __init_ _
Desired_capabilities=desired_capabilities)
File "D:\Program files\python\python3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 154, in __init __
Self.start_session (Desired_capabilities, Browser_profile)
File "D:\Program files\python\python3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 243, in Start_ Session
Response = Self.execute (command.new_session, parameters)
File "D:\Program files\python\python3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 312, in Execute
Self.error_handler.check_response (response)
File "D:\Program files\python\python3\lib\site-packages\selenium\webdriver\remote\errorhandler.py", Line 242, in Check_response
Raise Exception_class (message, screen, stacktrace)
Selenium.common.exceptions.WebDriverException:Message:unknown error:unrecognized Blink Revision: a10b9cedb40738cb152f8148ddab4891df876959
(Driver info:chromedriver=2.10.267521,platform=windows NT 6.3 x86_64)

How to resolve:

Webdriver when initializing, specify the path where the browser is located

When declaring Webdriver, add a sentence and run it again:

Path = "C:\Program Files (x86) \google\chrome\application\chromedriver.exe"

Self.driver = Webdriver. Chrome (Executable_path=path)

2. The element cannot be found according to the position:

(1) Possible situation one: because the window of the current browser is switched (the new Jump window).

Workaround: Before positioning, switch the window first

Handles = driver.window_handles # all Windows
print ' * ' *20,handles
For handle in handles:
If Handle!=driver.current_window_handle:
print ' Switch to ', handle
Driver.switch_to_window (handle)
Print Driver.current_window_handle # Printing window Handle--name
Break

(2) Possible situation two: Because the currently positioned IFrame has changed.

Workaround: Before positioning, switch the frame

Driver.switch_to_frame ("Rightframe")

(3) Possible three: run too fast, the page is not fully loaded.

Workaround: Hibernate for 1 seconds (or more seconds) before locating

Time.sleep (1)

Python+selenium frequently asked questions how to solve

Related Article

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.