2

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.

Nimantha
  • 6,405
  • 6
  • 28
  • 69
dushkin
  • 1,939
  • 3
  • 37
  • 82

2 Answers2

1

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

George Ogden
  • 596
  • 9
  • 15
0

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.

JeffC
  • 22,180
  • 5
  • 32
  • 55
  • I would expect Selenium to deal with at least alsmost every Chrome feature. But maybe it is really not supported yet... – dushkin Aug 15 '16 at 06:58
  • I must say that I disable the plugin but it always launches again when I run my code... :( – dushkin Aug 15 '16 at 10:51
  • 2
    Selenium will not ever support browser specific UI elements. That's not it's intent. The intent of Selenium is to automate interactions with the webpage that happens to be hosted in a particular browser. – JeffC Aug 15 '16 at 14:25
  • 1
    @Confiqure ...yes it does. This answer explains why there is no way to do what OP asked. – Michael Parker Aug 15 '16 at 17:46
  • @Confiqure The question is, "Is there a way to mute a tab?" and the answer is, No. I just explained why the answer is no and gave a possible (but unlikely) workaround. – JeffC Aug 15 '16 at 19:23