Cheng
Cheng

Reputation: 206

How to close Microsoft Edge Download Pop up or their notification

enter image description here

enter image description here

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

Answers (3)

Jansen Simanullang
Jansen Simanullang

Reputation: 2225

The following code has been tested:

Import necessary packages

from selenium import webdriver
from selenium.webdriver.edge.service import Service
from selenium.webdriver.edge.options import Options

Set up Edge 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")

Set up the Edge WebDriver service after the preferences have been set

service = Service(WEBDRIVER_PATH)
driver = webdriver.Edge(service=service, options=edge_options)

Upvotes: 0

Yu Zhou
Yu Zhou

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

Hassan Tariq
Hassan Tariq

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:

  1. Disable Pop-ups: self.edge_options.add_argument("--disable-popup-blocking")
  2. Disable Infobars: self.edge_options.add_argument("--disable-infobars")
  3. Disable Extensions: self.edge_options.add_argument("--disable-extensions")
  4. Use Specific Profile: self.edge_options.add_argument("user-data-dir=/path/to/profile") You can create a separate user profile to store your preferences.Remember to experiment with these options one at a time or in combination to find the most effective solution for your specific case.

Upvotes: 0

Related Questions