3

I am testing my website using Selenium and I am able to open chrome with --auto-select-desktop-capture-source="tab_name" and select the tab when screen share is enabled. Now I want the audio playing in the tab to be in my stream along with the video. While doing it manually there is a checkbox which enables audio sharing but is there something which can help enable it from Selenium?

Here is a fiddle: https://jsfiddle.net/john_vera/yr2k9xob/5/ Notice the Share Audio checkbox after selecting chrome tab in the dialog. I want to check that from Selenium.

John Vera
  • 59
  • 1
  • 3

1 Answers1

3

You could create an custom chromium build and implement an bypass for this dialog. To build chromium you can use these instructions (for windows): Here

Here the bypass in file display_media_access_handler.cc:

Look for this line:

// Orignal code
pending_request.picker->Show(picker_params, std::move(source_lists), std::move(done_callback));

And replace it with this

// Bypass dialog
content::DesktopMediaID screenSource(content::DesktopMediaID::TYPE_SCREEN, content::DesktopMediaID::kNullId, web_contents);
screenSource.audio_share = true;

OnPickerDialogResults(web_contents, screenSource);
// End of bypass

I testet it with Chromium Version 84.

Alex
  • 88
  • 7
  • 1
    I tried to build Chromium version 83 on Mac and 85 on Ubuntu with `content::DesktopMediaID::TYPE_WEB_CONTENTS`, but while testing i am getting the following error : `Error starting tab capture` Is there anything else I should be changing? – Nija Jun 16 '20 at 00:21
  • @Nija I think that if you change the type to TYPE_WEB_CONTENTS chrome needs to know the tab which should be shared, the following parameters may need to be changes also. You can try to add log-messages to the dialog to find out the right parameters for sharing a browser tab and adapt the code accordingly. I did the same for sharing the whole desktop. – Alex Aug 14 '20 at 10:20