1

I am working on making a tiny Java app of which needs to open a Firefox browser in hidden mode and also have it be muted.

As you can see by the code below, I have found a way to have the browser be hidden. However I am having some issues figuring out, how to mute the browser and whether it is actually even possible to do.

Considering the following answer I figured it may be possible, I know the answer is for Python but it's using the selenium webdriver, however for Chrome, where I need it for Firefox.

I tried to insert the following line firefoxBinary.addCommandLineOptions("--mute-audio"); however that didn't seem to work.

The following is what I currently have.

    WebDriver driver;

    FirefoxBinary firefoxBinary = new FirefoxBinary();
    firefoxBinary.addCommandLineOptions("--headless");

    System.setProperty("webdriver.gecko.driver", driverPath);

    FirefoxOptions firefoxOptions = new FirefoxOptions();
    firefoxOptions.setBinary(firefoxBinary);

    driver = new FirefoxDriver(firefoxOptions);
DevLiv
  • 573
  • 7
  • 19

1 Answers1

1

After further investigation, the following code fixed the issue of muting Geckodriver in Java, using Selenium. I added this code below the firefoxOptions.setBinary(firefoxBinary); line of my script above.

FirefoxProfile firefoxProfile = new FirefoxProfile();
firefoxProfile.setPreference("media.volume_scale", "0.0");
firefoxOptions.setProfile(firefoxProfile);
DevLiv
  • 573
  • 7
  • 19