How can I run my selenium web driver in firefox private mode instead of just normal firefox?
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
:
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)