I am currently trying to run some tests made with webdriverjs and chromedriver but they need microphone permissions.
This is the popup that shows up:
I have tried:
chromedriver.start(['--disable-popup-blocking']);
driver = new Webdriver.Builder()
.withCapabilities(Webdriver.Capabilities.chrome())
.build();
but it didn't work.
I also tried
driver.wait(Until.alertIsPresent(), config.TIMEOUT, 'Alert did not show up');
driver.switchTo().alert().accept();
it did not work either! I guess that this is not an ordinary alert.
Useful links:
Chrome options for java and ruby
How do i give them permissions programatically?
Is there any flag or some other way around this?
You can whitelist a url for audio-capture by providing chromedriver with the hardware.audio_capture_allowed_urls preference.
A fresh profile is loaded each time you run selenium, hence changes you make to the preferences and website permissions are not preserved between sessions. To amend this we need to tell selenium which profile to load.
Step 1. Find your Chrome preferences file: www.forensicswiki.org/wiki/Google_Chrome#Configuration
Step 2. Copy the folder
Default
somewhere. I will assume it is copied to/some/path/allow-mic/Default
.Alternative Step 3 (this is easier): Before copying
Default
visitlocalhost:1337
with Chrome and set mic to always allow.Step 3. Edit
allow-mic/Default/Preferences
, find the tags"profile"
,"content_settings"
and"exceptions"
within each other and addto
"exceptions"
. You should end up with something like:Step 4: Configure
selenium
to use the edited preferences:You can check that the correct set of preferences (Profile path) are in use by opening
chrome://version/
.A little late but pasting how to do this here for others looking for the same.
For those using Python, this worked for me: