Search code examples
seleniumwebrtcbrowserstack

How to allow microphone in BrowserStack using capabilities


I am trying to test a WebRTC application using BrowserStack to check the behavior through different browsers. I have a selenium script which is working on my local machine and also I have implemented the BroswerStack project https://github.com/browserstack/testng-browserstack including my selenium script.

The situation is that at the execution moment in BrowserStack, the script is stuck in the allow microphone part.

I had tried passing this argument "use-fake-ui-for-media-stream" as part of the capabilities in this way:

"chrome": {
      "os": "Windows",
      "os_version": "8",
      "browser": "Chrome",
      "browser_version": "70.0",
      "resolution": "1920x1080",
      "args":["use-fake-ui-for-media-stream"]
}

The way that I used to pass arguments in my local script is different due to I'm using a specific driver. Example:

ChromeOptions ops = new ChromeOptions();
ops.addArguments("use-fake-ui-for-media-stream");
WebDriver driver = new ChromeDriver(ops);

Maybe the problem is related to the way that I instance the remote web driver used by BroserStack

driver = new RemoteWebDriver(
                new URL("http://" + username + ":" + accessKey + "@" + config.get("server") + "/wd/hub"), capabilities);

Solution

  • My partner gave me the answer. The correct way to configure the argument is:

    "chrome": {
          "os": "Windows",
          "os_version": "8",
          "browser": "Chrome",
          "browser_version": "70.0",
          "resolution": "1920x1080",
          "chromeOptions": {"args":["use-fake-ui-for-media-stream"]}