Selenium version installed after the start of Firefox exception: ' Geckodriver ' executable needs to IS in PATH
Selenium silently upgrade to 3.0, however, the online tutorials are based on selenium2, recently a lot of small partners stepped on the pit, decided that it is necessary to out this article, to help the newly-started small partners to solve the environmental problems.
Selenium+python Environment collocation:
Selenium2+firefox46 the following version (without driver package, Firefox likes to sneak upgrade, you know)
selenium3+firefix47 above (must download driver: Geckodriver.exe, and add to environment variable)
First, encountered an exception
1. After installing selenium, then cmd into the python environment
2. Import Webdriver from Selenium
3. Start the Firefox browser
>>python
>>from Selnium Import Webdriver
>>webdriver. Firefox ()
The following exception appears: ' Geckodriver ' executable needs to IS in PATH
Second, the solution
1. ' Geckodriver ' executable needs to IS in PATH, which means that the Geckodriver.exe driver file needs to be added to the environment variable,
SELENIUM2 is the default support for Firefox, do not need a driver package, however, selenium3 need to support the driver package, so there is the above problem
2. Workaround one: Continue to use selenium3, to download the driver package, and then add to the environment variable (not recommended, because after the problem is resolved, there will be other problems later)
3. Workaround two: selenium3 downgrade to Selenium2 (next introduction)
Third, check the PIP environment
1. Open cmd, enter Pip, check the PIP environment is normal
>>pip
2. If the input pip appears prompt: did not provide a command description PIP environment has a problem, temporary solution, enter the pip when the suffix pip.exe can be, specific reasons to see the next solution.
Third, Pip view Selenium version number
1. Open cmd, enter pip show selenium
>>pip Show Selenium
2. Look at the Red area position version number display: 2.53.0, display is the current version number used
(If you're showing a 3.0 start, you'll need the next step)
Five, Pip downgrade selenium
1. To avoid conflicts with previously installed selenium versions, locate the selenium3.0 directory: Python\lib\site-packages directory
You can delete all the files in the beginning of the selenium. All of Python's third-party packages are under this directory.
2. Open cmd, enter pip install selenium==2.53.6 (Note is two = =, do not leave a blank in the middle, 2.53.6 version recommended here)
>>pip Install selenium==2.53.6
Six, upgrade the PIP version
1. If the following red areas appear in the PIP process, that is, the PIP version is too low, it is recommended to upgrade
2. How do I upgrade pip? Look at the last word: python-m pip install--upgrade pip
3. Follow the instructions above to knock it over again.
Selenium2+python Automated 2-PIP downgrade selenium3.0