dushkin
dushkin

Reputation: 2101

Selenium ChromeDriver - Muting a tab

Is there a way to mute a tab? Meaning shutting its audio. I was trying to come out from

ArrayList<String> tabs = new ArrayList<String> (m_chromeWebdriver.getWindowHandles());
m_chromeWebdriver.switchTo().window(tabs.get(1));

and to work on the tab, but I couldn't find a way.

Upvotes: 2

Views: 987

Answers (2)

George Ogden
George Ogden

Reputation: 815

You can mute all tabs using

from selenium import webdriver

# in Chrome:
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--mute-audio")
driver = webdriver.Chrome(chrome_options=chrome_options)

# in FireFox
profile = webdriver.FirefoxProfile()
profile.set_preference("media.volume_scale", "0.0")
driver = webdriver.Firefox(firefox_profile=profile)

According to this answer

Upvotes: 1

JeffC
JeffC

Reputation: 25611

Selenium doesn't interact with the browser UI. The only way you might be able to do it indirectly is if there were a keyboard shortcut but I haven't seen one.

Upvotes: 0

Related Questions