Python 2.7+selenium+firefox 55.0.3
Code:
fromSeleniumImportWebdriver fromSelenium.common.exceptionsImportnosuchelementexception fromSelenium.webdriver.common.keysImportKeysImportTimebrowser= Webdriver. Firefox ()#Get Local session of FirefoxBrowser.get ("http://www.yahoo.com")#Load Pageassert "Yahoo !" inchBrowser.titleelem= Browser.find_element_by_name ("P")#Find the Query boxElem.send_keys ("SELENIUMHQ"+Keys.return) Time.sleep (0.2)#Let the page load, would be is added to the APITry: Browser.find_element_by_xpath ("//a[contains (@href, ' http://seleniumhq.org ')]")exceptnosuchelementexception:assert0,"can ' t find SELENIUMHQ"browser.close ()
The error message is as follows:
Selenium.common.exceptions.WebDriverException:Message: ' geckodriver ' executable needs to is in PATH.
Answer Picks: https://www.zhihu.com/question/49568096
1. Selenium 3.x, webdriver/firefox/webdriver.py __init__, executable_path= "Geckodriver"; 2.x is executable_path= " Wires
2. Firefox 47 or above, need to download third party driver, namely Geckodriver;http/docs.seleniumhq.org/download/ Third party Drivers, Bindings, and plugins below to find Mozilla Geckodriver, download to any computer any directory (Mac down to/usr/bin/and/sbin/,/bin/,/usr/ local/bin/), add the path to the PC's path (for Windows) after decompression.
Iceblue Iceblue
Links: https://www.zhihu.com/question/49568096/answer/119324584
Source: Know
Copyright belongs to the author. Commercial reprint please contact the author for authorization, non-commercial reprint please specify the source.
Python Selenium module uses error-selenium.common.exceptions.webdriverexception:message: ' Geckodriver ' executable needs to IS in PATH.