'How can I mute the browser/tab in selenium using the geckodriver
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?
Solution 1:[1]
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")
For Selenium V4:
from selenium.webdriver.firefox.options import Options
options = Options()
options.set_preference("media.volume_scale", "0.0")
driver = webdriver.Firefox(options=options)
driver.get("https://www.youtube.com/watch?v=TUVcZfQe-Kw")
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | richardec |