如何允许或拒绝通知地理位置麦克风摄像头弹出
- 2025-02-14 09:49:00
- admin 原创
- 51
问题描述:
我无法点击访问摄像头身份验证弹出窗口的“允许”按钮。
这是弹出窗口的样子。
解决方案 1:
要Allow
或的Block
通知Microphone
,,,访问使用您必须使用类如下Camera
:GeoLocation
Notification
Selenium
ChromeOptions
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", { \n "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:UtilityBrowserDriverschromedriver.exe')
driver.get('https://www.google.co.in')
print("Page Title is : %s" %driver.title)
driver.quit()
解决方案 2:
这个 Java 代码帮助了我
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);
}
解决方案 3:
这对我有用:
driver.execute_cdp_cmd(
"Browser.grantPermissions",
{
"origin": TARGET_URL , # e.g https://www.google.com
"permissions": ["geolocation", "audioCapture", "displayCapture", "videoCapture",
"videoCapturePanTiltZoom"]
},
)
相关推荐
热门文章
项目管理软件有哪些?
热门标签
云禅道AD