这个错误讯息…
WebDriverException: 'geckodriver' executable needs to be in PATH.
…意味着在预期的默认 位置找不到GeckoDriver
。
解
当您使用基于MAC系统,你需要通过按键executable_path与沿值指的是绝对路径的的GeckoDriver如下:
from selenium import webdriverbrowser = webdriver.Firefox(executable_path='/usr/local/bin/geckodriver')
Additional Consideration
Ensure the following :
- GeckoDriver is present in the specified location.
- GeckoDriver is having executable permission for non-root users.
- Execute your @Test as a non-root user.



