在Python Selenium上使用ChromeDriver搜索时禁用GPS位置警报

2024-05-19 05:21:07 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个python脚本,它使用chromedriver和selenium搜索Bing。使用移动仿真时,某些搜索会触发GPS位置警报通知。我的问题是,如何在Chrome上完全禁用这些警报?在

我尝试了以下几点,但运气不佳:

UA_MOBILE = { "deviceName": "Apple iPhone 6 Plus" }

chromeOptionsMobile = webdriver.ChromeOptions()
chromeOptionsMobile.add_experimental_option('mobileEmulation', UA_MOBILE)

prefs = {
    'profile.default_content_setting_values.notifications' : 2,
    'profile.default_content_setting_values.geolocation' : 2,
    'profile.default_content_setting_values.popups' : 2,
    }

chromeOptionsMobile.add_experimental_option('prefs', prefs)

警报图像:GPS Location Alert

有什么想法吗?在


Tags: 脚本adddefault警报contentmobileprofilesetting

热门问题