testing using selenium: chrome screensharing auto select tab and share with audio

3.2k Views Asked by At

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.

1

There are 1 best solutions below

2
On

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.