[英]How to open a private firefox window - selenium
How can I run my selenium web driver in firefox private mode instead of just normal firefox? 如何在Firefox私有模式下而不是仅在普通的Firefox下运行Selenium Web驱动程序?
I tried the below but it hasn't worked: 我尝试了以下操作,但没有成功:
firefox_profile = webdriver.FirefoxProfile()
firefox_profile.set_preference("browser.privatebrowsing.autostart", True)
driver = webdriver.Firefox(firefox_profile=firefox_profile)
I viewed the question asked before which is mentioned in the comment and above the question but it didn't work. 我查看了之前在评论中和问题上方提到的问题,但没有成功。
You could use FirefoxBinary
and add_command_line_options
: 您可以使用
FirefoxBinary
和add_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)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.