selenium.common.exceptions.WebDriverException:消息:“geckodriver"可执行文件需要在 GeckoDriver Selenium Firefox 的 PATH 中 [英] selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH with GeckoDriver Selenium Firefox
问题描述
我对 Pycharm 或 Python 不太了解,无法解决问题所在.在我看来,这只是一段代码应该被执行,但我得到了一堆对我来说毫无意义的文本.
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.
任何其他使用 Selenium 的人都收到此错误并知道如何修复它?物理代码 -
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
执行代码
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()
推荐答案
错误说明了一切:
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
这意味着 GeckoDriver 二进制文件不在 Classpath
Which implies that GeckoDriver binary is not in the Classpath
在使用 Selenium v3.x 时,您必须从 url 并将其存储在您的系统中,并在启动 webdriver 和 Web 浏览器时提及绝对路径 会话如下:
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()
这篇关于selenium.common.exceptions.WebDriverException:消息:“geckodriver"可执行文件需要在 GeckoDriver Selenium Firefox 的 PATH 中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!