I'm not able to click on Allow button of access camera authentication pop up.
Here is the look of pop up.
I'm not able to click on Allow button of access camera authentication pop up.
Here is the look of pop up.
To Allow
or Block
the notification of Microphone
, Camera
, GeoLocation
, Notification
access using Selenium
you have to use ChromeOptions
Class as follows :
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
opt = Options()
opt.add_argument("--disable-infobars")
opt.add_argument("start-maximized")
opt.add_argument("--disable-extensions")
# Pass the argument 1 to allow and 2 to block
opt.add_experimental_option("prefs", { \
"profile.default_content_setting_values.media_stream_mic": 1,
"profile.default_content_setting_values.media_stream_camera": 1,
"profile.default_content_setting_values.geolocation": 1,
"profile.default_content_setting_values.notifications": 1
})
driver = webdriver.Chrome(chrome_options=opt, executable_path=r'C:\Utility\BrowserDrivers\chromedriver.exe')
driver.get('https://www.google.co.in')
print("Page Title is : %s" %driver.title)
driver.quit()
This java code helped me
public WebDriver initWebDriver() {
ChromeOptions options = new ChromeOptions();
options.addArguments("use-fake-device-for-media-stream");
options.addArguments("use-fake-ui-for-media-stream");
prefs = new HashMap<String, Object>();
prefs.put("profile.default_content_setting_values.media_stream_mic", 1);
prefs.put("profile.default_content_setting_values.media_stream_camera", 1);
prefs.put("profile.default_content_setting_values.geolocation", 1);
prefs.put("profile.default_content_setting_values.notifications", 1);
options.setExperimentalOption("prefs", prefs);
System.setProperty(CHROME_DRIVER, DRIVER_PATH);
return new ChromeDriver(options);
}
This worked for me:
driver.execute_cdp_cmd(
"Browser.grantPermissions",
{
"origin": TARGET_URL , # e.g https://www.google.com
"permissions": ["geolocation", "audioCapture", "displayCapture", "videoCapture",
"videoCapturePanTiltZoom"]
},
)
© 2022 - 2024 — McMap. All rights reserved.