Python:Selenium无法启动firefox浏览器

时间:2020-01-28 13:50:01

标签: python selenium firefox webdriver

尝试通过webdriver运行firefox,但是firefox无法运行。正确指定所有内容(firefox路径),即使什么也没有发生。 非常感谢您的帮助。

[*] geckodriver.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 Files\Mozilla Firefox\Firefox.exe")#path of Firefox.exe
driver = webdriver.Firefox(firefox_binary=binary)
driver.get("https://google.com")

1 个答案:

答案 0 :(得分:1)

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

driver = webdriver.Firefox(executable_path="path\to\geckodriver.exe")

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