Search code examples
pythonseleniumselenium-webdriverselenium-firefoxdriverfirefox-developer-tools

Why does firefox ignore media.peerconnection.enabled option?


I write automate bot in selenium and think a little about anonymity so I suggest to disable WebRTC in firefox driver by this command options.set_preference("media.peerconnection.enabled", False) but when I start code and in "about:config" looks to check it - it is enabled(True but should be False). Minimum code for test(Python):

from seleniumwire import webdriver

options = webdriver.FirefoxOptions()
options.set_preference("media.peerconnection.enabled", False)

driver = webdriver.Firefox(executable_path="geckodriver.exe")
driver.get("https://iphey.com")

Solution

  • I should use a FirefoxProfile() so:

    from seleniumwire import webdriver
    options = webdriver.FirefoxOptions()
    fp = webdriver.FirefoxProfile() 
    
    fp.set_preference("media.peerconnection.enabled", False)
    fp.update_preferences()
    driver = webdriver.Firefox(fp, executable_path="geckodriver.exe")
    driver.get("https://iphey.com")