selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH with GeckoDriver Selenium Firefox

我的未来我决定 提交于 2019-12-02 06:50:24

问题


I don't know Pycharm - or Python well enough to troubleshoot just what went wrong. It seems top me as if this simply bit of code should execute but I get a jumble of text that says nothing to me.

Anyone else using Selenium get this error and know how to fix it? The physical code -

"C:\Users\Noah Linton\PycharmProjects\EdgenuityBot\venv\Scripts\python.exe" 
"C:/Users/Noah Linton/PycharmProjects/EdgenuityBot/Edgenuity Bot"
Traceback (most recent call last):
  File "C:\Users\Noah Linton\PycharmProjects\EdgenuityBot\venv\lib\site-
packages\selenium\webdriver\common\service.py", line 76, in start
    stdin=PIPE)
  File "C:\Program Files (x86)\Microsoft Visual 
Studio\Shared\Python36_64\Lib\subprocess.py", line 709, in __init__
    restore_signals, start_new_session)
  File "C:\Program Files (x86)\Microsoft Visual 
Studio\Shared\Python36_64\Lib\subprocess.py", line 997, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:/Users/Noah Linton/PycharmProjects/EdgenuityBot/Edgenuity Bot", line                         
3, in <module>
driver = webdriver.Firefox()
File "C:\Users\Noah Linton\PycharmProjects\EdgenuityBot\venv\lib\site-
packages\selenium\webdriver\firefox\webdriver.py", line 148, in __init__
self.service.start()
File "C:\Users\Noah Linton\PycharmProjects\EdgenuityBot\venv\lib\site-
packages\selenium\webdriver\common\service.py", line 83, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' 
executable needs to be in PATH. 


Process finished with exit code 1

The executive code

 from selenium import webdriver

driver = webdriver.Firefox()
driver.get("https://auth.edgenuity.com/Login/Login/Student")
button = driver.find_element_by_id('LoginSubmit')
button.click()

回答1:


The error says it all :

selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH. 

Which implies that GeckoDriver binary is not in the Classpath

While working with Selenium v3.x you have to download the latest GeckoDriver from this url and store it in your system and mention the absolute path while initiating the webdriver and Web Browser session as follows :

from selenium import webdriver

driver = webdriver.Firefox(executable_path="C:\\path\\to\\geckodriver.exe")
driver.get("https://auth.edgenuity.com/Login/Login/Student")
button = driver.find_element_by_id('LoginSubmit')
button.click()



回答2:


For what little help it might be, the critical parts of the traceback are

FileNotFoundError: [WinError 2] The system cannot find the file specified

line 3, in <module>
driver = webdriver.Firefox()

selenium.common.exceptions.WebDriverException: Message: 'geckodriver' 
executable needs to be in PATH.

It seems that the Firefox webdriver isn't in the defined search path that your main program sees. There's something called geckodriver that isn't available.

Check your installation and configuration for this package. Consult with your class instructors and classmates for help. I suspect that the repair is something with your local set-up, beyond our knowledge here.



来源:https://stackoverflow.com/questions/48551161/selenium-common-exceptions-webdriverexception-message-geckodriver-executable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!