chrome_options = webdriver.ChromeOptions()
# Set preferences
prefsNotifications = {"profile.default_content_setting_values.notifications" : 2}
prefsPopups = {"profile.default_content_settings.popups": 0}
prefsDownload = {"download.default_directory": CurDir}
prefsSafe = {'safebrowsing.enabled': 'false'}
chrome_options.add_experimental_option("prefs", prefsNotifications)
chrome_options.add_experimental_option("prefs", prefsPopups)
chrome_options.add_experimental_option("prefs", prefsDownload)
chrome_options.add_experimental_option("prefs", prefsSafe)
driver = webdriver.Chrome(CurDir+"\\chromedriver.exe", chrome_options=chrome_options)
driver.maximize_window()
return driver
第5行和第9行,通知:下载时文件不安全。我删除了这两行。它无法保存在我想要的磁盘中。
如何解决此问题?
答案 0 :(得分:0)
def OpenBrowser():
chromeOptions = webdriver.ChromeOptions()
prefs = {"download.default_directory" : CurDir,"safebrowsing.enabled": "false","profile.default_content_setting_values.notifications" : 2, "profile.default_content_settings.popups": 0}
chromeOptions.add_experimental_option("prefs",prefs)
driver = webdriver.Chrome(executable_path = CurDir+"\\chromedriver.exe", chrome_options = chromeOptions)
driver.maximize_window()
return driver
通过selenium功能打开chromedriver.exe,没有任何通知,警告或弹出窗口。 1个偏好。