1

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.

BruceyBandit
  • 3,978
  • 19
  • 72
  • 144
  • Possible duplicate of [Python/Selenium incognito/private mode](http://stackoverflow.com/questions/27630190/python-selenium-incognito-private-mode) – Mosam Mehta Feb 17 '16 at 12:48
  • You May Like To See This : [Python/Selenium incognito/private mode](https://stackoverflow.com/a/51023783/9989034) – A_Asaker Jul 06 '19 at 16:03

1 Answers1

0

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)
Padraic Cunningham
  • 176,452
  • 29
  • 245
  • 321