Python Selenium fails to start a new version of Firefox problem solution
Firefox version 45 and above cannot be started directly using selenium-3.0.1. The following steps are required:
(1) Download geckodriver.exe
https://github.com/mozilla/geckodriver/releases
After decompression, place it in
1. Check the webdriver.py in C:\Python27\Lib\site-packages\selenium\webdriver\firefox , in the def_init_ function, executable_path="geckodriver", the previously built environment is executable_path="wires" ;
2. geckodriver is an original third-party browser. For selenium3.x version, geckodriver will be used to drive firefox , so you need to download geckodriver.exe, download address: https://github.com/mozilla/geckodriver/releases
3. Put it in C:\Python27 (check whether the path of C:\Python27 is added to the environment variable path ),
(2)
from selenium import webdriver
fromselenium.webdriver.common.desired_capabilities import DesiredCapabilities
fromselenium.webdriver.firefox.firefox_binary import FirefoxBinary
binary = FirefoxBinary(r'C:\ProgramFiles (x86)\Mozilla Firefox\firefox.exe')
driver =webdriver.Firefox(firefox_binary=binary)
driver.get('http://www.google.com')