Objective
There are a lot of small partners in the installation of selenium environment after the Firefox error, because now selenium upgrade to 3.0, and 2.0 of the version there is a little difference.
There are three main pits encountered during the installation environment:
1.' geckodriver ' executable needs to is in PATH
2.expected browser binary location, but unable to find binary in default location
3.unsupported Marionette Protocol version 2, required 3
Environment Preparation:
--python3.6
--selenium3.0
--firefox50
First, install Python
1. Install python This simple, download version after the idiot installation on the line.
2. After the installation, look at this directory D:\python\Scripts, there are no pip.exe and easy_install.exe (generally, there is no need to reinstall once)
3. Add D:\python and D:\python\Scripts to the environment variable path
Second, check the PIP tool
1. Open cmd, enter: Pip, appear as interface, indicating PIP environment OK.
>>pip
2. If there is an exception prompt: Did not provide a command, see this solution: Selenium2+python Automation 3-Resolving PIP usage exceptions
Third, installation selenium3.0
1.cmd Input: Pip install Selenium
>>pip Install Selenium
2. First install to see 100% complete, halfway through the failure to re-enter several times to install.
Iv. Checking the Selenium environment
1. In cmd, enter the following command to check the environment
>>python
>>from Selenium Import Webdriver
>>driver=webdriver. Firefox ()
>>driver.get ("https://www.baidu.com")
2. You can see the normal start of the browser, indicating that the environment OK, if you encounter an exception, continue to see the following solution.
V. Encounter the first pit:' geckodriver ' executable needs to being in PATH
1. If the following error is reported during startup of the browser
Traceback (most recent):
File "<stdin>", line 1, in <module>
File "D:\test\python3\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 145, in __init__
Self.service.start ()
File "D:\test\python3\lib\site-packages\selenium\webdriver\common\service.py", line Bayi, in Start
Os.path.basename (Self.path), self.start_error_message)
Selenium.common.exceptions.WebDriverException:Message: ' geckodriver ' executable needs to is in PATH.
2. This is because the latest selenium3.0 startup Firefox needs to geckodriver.exe this driver file.
3. After downloading, configure to the environment variable path (you can directly put the Python root directory)
Six, encountered the second pit:expected browser binary location, but the unable to find binary in the default location
1. If the following error is reported during startup of the browser
Traceback (most recent):
File "<stdin>", line 1, in <module>
File "D:\test\python3\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 155, in __init__
Keep_alive=true)
File "D:\test\python3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line __init__
Self.start_session (Desired_capabilities, Browser_profile)
File "D:\test\python3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 179, in Start_session
Response = Self.execute (command.new_session, capabilities)
File "D:\test\python3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 238, in Execute
Self.error_handler.check_response (response)
File "D:\test\python3\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 193, in Check_response
Raise Exception_class (message, screen, stacktrace)
Selenium.common.exceptions.WebDriverException:Message:expected browser binary location, but unable to find binary in default location, no ' moz:firefoxOptions.binary ' Capabi Lity provided, and no binary flag set on the command line
2. This is because firefox.exe this file also needs to be configured to the environment variable under path
3. This path is installed after Firefox, find firefox.exe This file address, add to Path
Vii. encountering the third pit:unsupported Marionette Protocol version 2, required 3
1. If the following error occurs during startup of the browser
Traceback (most recent):
File "<stdin>", line 1, in <module>
File "D:\test\python3\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 155, in __init__
Keep_alive=true)
File "D:\test\python3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line __init__
Self.start_session (Desired_capabilities, Browser_profile)
File "D:\test\python3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 179, in Start_session
Response = Self.execute (command.new_session, capabilities)
File "D:\test\python3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 238, in Execute
Self.error_handler.check_response (response)
File "D:\test\python3\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 193, in Check_response
Raise Exception_class (message, screen, stacktrace)
Selenium.common.exceptions.WebDriverException:Message:Unsupported Marionette Protocol version 2, required 3
2. The reason for this error is that the Firefox version is too low, the latest version of selenium3.0 supports more than firefox47 versions, and the upgrade version is available.
Summary: The configuration of the entire environment is python3.6+selenium3.0+firefox47 above , of course, Python version 2.7 is also possible
Selenium3+python Automation 50-environment building (Firefox) "Reprint"