我不知道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()
答案 0 :(得分:1)
错误说明了一切:
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
这意味着 GeckoDriver 二进制文件不在 Classpath
中使用 Selenium v3.x 时,您必须从此url下载最新的 GeckoDriver 并将其存储在您的系统中并提及绝对路径启动 webdriver 和 Web浏览器会话,如下所示:
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()
答案 1 :(得分:0)
对于它可能没什么帮助,追溯的关键部分是
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.
似乎Firefox webdriver不在主程序看到的已定义搜索路径中。有一种名为geckodriver
的东西不可用。
检查此软件包的安装和配置。咨询您的班级教师和同学以寻求帮助。我怀疑修理是你当地的设置,超出我们的知识。