I have a HTML/Javascript file with google's web speech api and I'm doing testing using selenium, however everytime I enter the site the browser requests permission to use my microphone and I have to click on 'ALLOW'.
How do I make selenium click on ALLOW automatically ?
Extends Selenium WebDriver classes to include the request function from the Requests library, while doing all the needed cookie and request headers handling.
Handling permission pop-ups. While testing your mobile app, it may ask for specific permissions during the test. Various system dialogs or popups may appear, asking the user to grant access. The mobile app might ask the user permission to access the contacts, notifications, media, ... on the device.
Creating an instance of ChromeOptions class: See below code: ChromeOptions options = new ChromeOptions(); options. addArguments("disable-infobars"); ChromeDriver driver = new ChromeDriver(options);
Wrestled with this quite a bit myself.
The easiest way to do this is to avoid getting the permission prompt is to add --use-fake-ui-for-media-stream
to your browser switches.
Here's some shamelessly modified code from @ExperimentsWithCode's answer:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument("--use-fake-ui-for-media-stream")
driver = webdriver.Chrome(executable_path="path/to/chromedriver", chrome_options=chrome_options)
So I just ran into another question asking about disabling a different prompt box. It seems there may be a way for you to accomplish your goal.
This page lists options for starting chrome. One of the options is
--disable-user-media-security
"Disables some security measures when accessing user media devices like webcams and microphones, especially on non-HTTPS pages"
So maybe this will work for you:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument("--disable-user-media-security=true")
driver = webdriver.Chrome(executable_path="path/to/chromedriver", chrome_options=chrome_options)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With