Reputation: 206
I am using selenium to switch windows but I am trying to close these 2 as they pop up when it is in automation mode and it screws up the window_handles. Is there a way to stop them from showing up other than using headless mode.
I have tried using all these commands but the notifications/pop up are still showing.
self.edge_options = webdriver.EdgeOptions()
self.prefs = {
'download.default_directory': str(self.temp_path),
"download.prompt_for_download": False, # Disable download prompt
"download.directory_upgrade": True
}
self.edge_options.add_experimental_option('prefs', self.prefs)
self.edge_options.add_argument("--disable-notifications")
self.edge_options.add_argument("--no-download-notification")
Upvotes: 1
Views: 1609
Reputation: 2225
The following code has been tested:
from selenium import webdriver
from selenium.webdriver.edge.service import Service
from selenium.webdriver.edge.options import Options
edge_options = Options()
edge_options.use_chromium = True # Use Chromium-based Edge
prefs = {
"download.prompt_for_download": False,
"download.directory_upgrade": True,
"browser":{
"show_hub_popup_on_download_start": False
},
"user_experience_metrics":{
"personalization_data_consent_enabled": True
}}
edge_options.add_experimental_option('prefs', prefs)
edge_options.add_argument("--disable-notifications")
edge_options.add_argument("--no-download-notification")
service = Service(WEBDRIVER_PATH)
driver = webdriver.Edge(service=service, options=edge_options)
Upvotes: 0
Reputation: 12999
The first popup looks like Edge personalize prompt, you can disable the prompt and Edge download popup using the code below:
prefs = {
'browser':{
'show_hub_popup_on_download_start': False
},
'user_experience_metrics':{
'personalization_data_consent_enabled': True
}
}
edge_options.add_experimental_option('prefs', prefs)
Upvotes: 1
Reputation: 11
While you've already attempted to disable notifications with --disable-notifications and --no-download-notification, some websites may still manage to display pop-ups.You can try additional steps:
Upvotes: 0