I have a Selenium test I want to run in Edge against a page which uses the webcam and microphone. In order for those media devices to work in the browser, the user has to allow the site access to the device.
This is a quick example fiddle I made which illustrates that behaviour in Edge: https://jsfiddle.net/12t3nofL/
You should notice the popup bar at the bottom of the screen, I need this to be automatically allowed in my automation.
I found these existing Q/As on SO already which suggest there is a way to allow media devices via the webdriver options, but they just don't work for me:
how to allow mic/camera in edge web browse suing selenium
How to enable 'Mircophone' access in Edge browser using Selenium?
This is my code (you may need to pip install selenium==3.141.0
first):
from selenium import webdriver
from selenium.webdriver.edge.options import Options
options = Options()
options.set_capability("dom.webnotifications.enabled", 1)
options.set_capability("permissions.default.microphone", 1)
options.set_capability("permissions.default.camera", 1)
capabilities = options.to_capabilities()
driver = webdriver.Edge(capabilities=capabilities)
driver.get('https://jsfiddle.net/12t3nofL')
And the permissions bar still pops up at the bottom every time.
I am on Selenium 3.141.0 and Python 3.7.0 (though have the same issue in 2.7).
Note: due to other reasons, I have Edge set to clear sessions on exit so cookies and cache are not preserved - in an attempt to mimic the fresh profile you get with automated Chrome.