我不太了解Pycharm (或者Python ),也不知道到底出了什么问题。在我看来,这段简单的代码应该执行,但是我得到了一堆乱七八糟的文本,对我来说什么也说不出来。
其他使用Selenium的人会得到这个错误并知道如何修复它?物理密码-
"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
执行代码
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()
发布于 2018-02-01 16:34:16
这个错误说明了一切:
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
这意味着GeckoDriver二进制文件不在Classpath中。
在使用Seleniumv3.x时,您必须从这个GeckoDriver下载最新的https://github.com/mozilla/geckodriver/releases并将其存储在系统中,并在启动webdriver会话时提到绝对路径,如下所示:
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()
https://stackoverflow.com/questions/48551161
复制相似问题