How to disable the "some site wants to open this application" alert in Chrome using Selenium?

Question:

How to block this pop-up?

pop-up

An English equivalent would be:

This site is trying to open Spotify.

https://open.spotify.com wants to open this application.

□ Always allow open.spotify.com to open links of this type in the associated app

I tried to use:

options = webdriver.ChromeOptions()
options.add_argument("--disable-extensions")
options.add_argument('--disable-popup-blocking')
driver = webdriver.Chrome(options=options)
Asked By: ezbooz

||

Answers:

When running the Selenium webdriver, Chrome opens a new browsing session with the default Chrome profile (without any custom settings).

To get around this, you can set a profile directory by using the --user-data-dir=/your/profile/data/location argument. In this location Chrome will create a new profile location. When your script is running, manually navigate to the Chrome window that should have opened on your screen and simply enable the always open option.

The next time you run your script using the same profile directory you shouldn’t see this pop-up.

Answered By: Pawel Kam