Python :Selenium 不启动 Firefox 浏览器



尝试通过 webdriver 运行 Firefox,但 Firefox 无法运行。正确指定所有内容(火狐路径(,即使什么也没发生。 我真的很感激你的帮助。

[*]壁虎驱动程序.exe 已移至/USR/bin

from selenium import webdriver
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
binary = FirefoxBinary("C:Program FilesMozilla FirefoxFirefox.exe")#path of Firefox.exe
driver = webdriver.Firefox(firefox_binary=binary)
driver.get("https://google.com")

您必须将驱动程序放在 PATH 中,或者可以指定驱动程序的路径。

driver = webdriver.Firefox(executable_path="pathtogeckodriver.exe")

如果没有,可以从这里下载它并将其放在python文件夹中。

最新更新