Selenium2+python Automated 2-PIP Downgrade selenium3.0 (leisurely course)

Source: Internet
Author: User

Selenium version installed after the start of Firefox exception: ' Geckodriver ' executable needs to IS in PATH ( Cause analysis: Selenium silently upgrade to 3.0, but the online tutorials are based on selenium2.

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

1th step: After installing selenium, then cmd into the python environment

2nd step: Import Webdriver from Selenium

3rd step: Start the Firefox browser

>>python (corresponding to the 1th step)

>>from Selenium import webdriver (corresponding to 2nd step)

>>webdriver. Firefox () (for 3rd step, note F caps)

The following exception appears: ' Geckodriver ' executable needs to IS in PATH

Second, the solution

1. ' Geckodriver ' executable needs to IS in PATH, this sentence means, Geckodriver.exe driver files need to be added to the environment variable, SELENIUM2 is the default support Firefox, do not need the driver package, but, 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. Solution Two: Selenium3 downgrade to Selenium2 (this is the way I'm learning)

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 pip when add suffix pip.exe try, no words Baidu find solution.

Four, 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.6, 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. In order to avoid conflicts with the previously installed selenium version, first find the selenium3.0 directory: Python\lib\site-packages directory, the selenium in the beginning of all the files are deleted. 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 (leisurely course)

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.