Home > Software engineering >  How can I mute the browser/tab in selenium using the geckodriver
How can I mute the browser/tab in selenium using the geckodriver

Time:05-07

I'm trying to mute the browser/tab in selenium since headless mode doesnt mute sounds, I've searched but all I could find was chrome solutions and they didn't work, Also I don't want to use a profile

Is this possible on firefox/geckodriver?

CodePudding user response:

You can call set_preference("media.volume_scale", "0.0") in webdriver.FirefoxProfile() class

Code:

profile = webdriver.FirefoxProfile()
profile.set_preference("media.volume_scale", "0.0")

Full code example:

from selenium import webdriver


profile = webdriver.FirefoxProfile()
profile.set_preference("media.volume_scale", "0.0")


driver = webdriver.Firefox(firefox_profile=profile)
driver.get("https://www.youtube.com/watch?v=TUVcZfQe-Kw")
  • Related