Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
529 views
in Technique[技术] by (71.8m points)

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

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:UsersNoah LintonPycharmProjectsEdgenuityBotvenvScriptspython.exe" 
"C:/Users/Noah Linton/PycharmProjects/EdgenuityBot/Edgenuity Bot"
Traceback (most recent call last):
  File "C:UsersNoah LintonPycharmProjectsEdgenuityBotvenvlibsite-
packagesseleniumwebdrivercommonservice.py", line 76, in start
    stdin=PIPE)
  File "C:Program Files (x86)Microsoft Visual 
StudioSharedPython36_64Libsubprocess.py", line 709, in __init__
    restore_signals, start_new_session)
  File "C:Program Files (x86)Microsoft Visual 
StudioSharedPython36_64Libsubprocess.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:UsersNoah LintonPycharmProjectsEdgenuityBotvenvlibsite-
packagesseleniumwebdriverfirefoxwebdriver.py", line 148, in __init__
self.service.start()
File "C:UsersNoah LintonPycharmProjectsEdgenuityBotvenvlibsite-
packagesseleniumwebdrivercommonservice.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()
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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()

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...