简体   繁体   English

Python : Selenium 不启动 firefox 浏览器

[英]Python : Selenium does not start the firefox browser

Try to run firefox through webdriver, but firefox does not run.尝试通过webdriver运行firefox,但是firefox不运行。 Specify everything correctly (firefox path), even if nothing happened.正确指定所有内容(firefox 路径),即使什么也没发生。 I would really appreciate your help.我将衷心感谢您的帮助。

[*]geckodriver.exe was moved to / usr / bin [*]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")

You have to put the driver in your PATH, or you can specify the path to the driver.您必须将驱动程序放在 PATH 中,或者您可以指定驱动程序的路径。

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

If you have not, you can download it from here and put it in your python folder.如果你还没有,你可以从这里下载它并把它放在你的python文件夹中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM