如何打开firefox私有窗口selenium

2024-10-03 21:26:13 发布

您现在位置:Python中文网/ 问答频道 /正文

如何在firefox私有模式下运行selenium web驱动程序,而不仅仅是普通的firefox?在

我尝试了以下方法,但没有奏效:

firefox_profile = webdriver.FirefoxProfile()
firefox_profile.set_preference("browser.privatebrowsing.autostart", True)

driver = webdriver.Firefox(firefox_profile=firefox_profile)

我看了前面的问题,这个问题在评论和问题上面都提到过,但是没有起作用。在


Tags: 方法browserwebselenium驱动程序模式firefoxprofile
1条回答
网友
1楼 · 发布于 2024-10-03 21:26:13

您可以使用FirefoxBinaryadd_command_line_options

from selenium import webdriver
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary

b = firefox_binary=FirefoxBinary('/usr/bin/firefox')
b.add_command_line_options("-private")
dr = webdriver.Firefox(firefox_binary=b)

相关问题 更多 >