I can now see why you initially offered a 50 point bounty on this question, because it is a very complex problem to solve via Selenium.
SOLVED -- 02/05/2021
This should have not been this difficult to solve!! I'm totally amazed at all of the posts across multiple forums on this issue. Solving this took lot of trails and errors.
Step 1:
Open Microsoft Edge and navigate to a site that invokes the dialog as shown below.
Step 2:
Check the box - Allows allow to open links of this type in the associated app. Click Open. Close the associated app and shutdown Microsoft Edge.
Step 3:
reopen Microsoft Edge and navigate to edge://settings/content/applicationLinks
The application(e.g., zoom) is now allowed to automatically open.
Step 4:
Close Microsoft Edge and launch Selenium with the following code:
from msedge.selenium_tools import Edge
from msedge.selenium_tools import EdgeOptions
edge_driver = '/usr/local/bin/msedgedriver'
edge_options = EdgeOptions()
edge_options.use_chromium = True
edge_options.add_argument("user-data-dir=/Users/user_name/Library/Application Support/Microsoft Edge/User Data")
edge_options.add_argument("profile-directory=Profile 1")
edge_options.add_experimental_option("useAutomationExtension", False)
edge_options.add_experimental_option("excludeSwitches", ['enable-automation'])
# I needed this to work on macOS
edge_capabilities = edge_options.capabilities
edge_capabilities["platform"] = "ANY"
edge_capabilities.update(edge_options.to_capabilities())
driver = Edge(executable_path=edge_driver, options=edge_options)
driver.get("https://zoom.us/j/000-000-000")
The zoom application will automatically open without the dialog.
It seems that either msedge or selenium is creating a new profile each time it was launched, which still happens, but now parameters from Profile 1 are being inherited.
UPDATE -- 02/04/2021
Based on lots of research it seems that this dialog CANNOT be handled when Selenium is controlling either Google Chrome, Microsoft Edge or Mozilla Firefox.
The dialog can be suppressed outside of Selenium using a variety of methods, including registry settings on Microsoft platforms running multiple versions of Windows, Property list(PLIST) on Apple platforms running macOS and even browser level switches.
BUT SO FAR NONE OF THESE METHODS HAVE WORK WITH SELENIUM
This dialog is being generated outside the browser (and Selenium) at the Operating System (OS) level. It seem that you have to deal with this dialog at the OS level when using Selenium.
These modules might be useful in dealing with this dialog at the OS level.
- win32gui - Microsoft
- win32com - Microsoft
- appscript - Apple
I found an issue similar to yours on Github under SeleniumHQ/selenium.
The issue AddUserProfilePreference: Protocol_handler was closed and never resolved.
ORIGINAL POST -- 01/31/2021
I have tired to bypass the dialog with:
driver.switch_to.alert.accept()
But this call throws this error:
selenium.common.exceptions.NoAlertPresentException: Message: no such alert (Session info: MicrosoftEdge=88.0.705.56)
I have tried to pass these options individually and in groups with EdgeOptions():
edge_options.add_argument("--disable-popup-blocking")
edge_options.add_argument('--disable-default-apps')
edge_options.add_argument('--allow-silent-push')
edge_options.add_argument('--disable-notifications')
edge_options.add_argument('--suppress-message-center-popups')
edge_options.add_argument('--inprivate')
But the dialog still shows up.
I have also tried this:
from msedge.selenium_tools import Edge
from msedge.selenium_tools import EdgeOptions
edge_driver = '/usr/local/bin/msedgedriver'
edge_options = EdgeOptions()
edge_options.use_chromium = True
prefs = {'profile.default_content_setting_values.notifications': 2}
edge_options.add_experimental_option('prefs', prefs)
edge_capabilities = edge_options.capabilities
# I needed this to work on macOS
edge_capabilities["platform"] = "ANY"
edge_capabilities.update(edge_options.to_capabilities())
driver = Edge(executable_path=edge_driver, capabilities=edge_capabilities)
driver.get("https://zoom.us/j/000-000-000")
But yet again the dialog pops-up.
I have also tried to edit the default Microsoft Edge profile. During this edit I allowed my test site (zoom.us) to do most things.
from msedge.selenium_tools import Edge
from msedge.selenium_tools import EdgeOptions
edge_driver = '/usr/local/bin/msedgedriver'
edge_options = EdgeOptions()
edge_options.use_chromium = True
edge_options.add_argument("user-data-dir=/Users/user_name/Library/Application Support/Microsoft Edge/User Data")
edge_capabilities = edge_options.capabilities
# I needed this to work on macOS
edge_capabilities["platform"] = "ANY"
edge_capabilities.update(edge_options.to_capabilities())
driver = Edge(executable_path=edge_driver, capabilities=edge_capabilities)
driver.get("https://zoom.us/j/000-000-000")
But the dialog still popped up, but the zoom application downloaded, which didn't happen before.
I have also tested dozens of these switches using edge_options.add_argument('switch_name'), but like before nothing worked.
So like I stated before this dialog isn't a normal Alert and it will likely require code or setting outside of Selenium. I'm trying to determine what additional measures are needed.
To me it seems that you need to find a python module or even an OS application that can determine either the PID or the focus on that popup. Once you can determine that via the OS you should be able to close the dialog.
I cannot test this Microsoft Windows example, which supposedly stops the dialog per site.
In this Microsoft Forum discussion users are discussing how to stop these alerts from happening in a Microsoft Edge browser. The users are suggesting enabling a PLIST for MacOS or a registry key for Microsoft OS.
I tested the PLIST, which worked in the Microsoft Edge browser, but only when it wasn't being controlled by selenium.
UPDATE -- 02-04-2021
I also tested these switches, which did not solve the dialog issue.
# references
#
# 1. https://chromium.googlesource.com/chromium/src/+/master/chrome/common/pref_names.cc
#
# 2. https://stackoverflow.com/questions/62926156/chrome-84-a-website-wants-to-open-this-application-handlers
#
# 3. https://support.google.com/chrome/a/thread/62872506?hl=en
#
# 4. https://bugs.chromium.org/p/chromium/issues/detail?id=982341
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
capabilities = DesiredCapabilities().CHROME
prefs = {"protocol_handler": {"allowed_origin_protocol_pairs": {"https://zoom.us/*": {"zoom.us": True}}}}
# prefs = {"protocol_handler": {"excluded_schemes": {"zoom": False}}}
# prefs = {"protocol_handler": {"policy.auto_launch_protocols_from_origins": {"https://zoom.us/*": {"zoom.us": True}}}}
# prefs = {"AutoLaunchProtocolsFromOrigins": [{"allowed_origins": ["*"], "protocol":"zoom.us"}]}
chrome_options.add_experimental_option('prefs', prefs)
capabilities.update(chrome_options.to_capabilities())
SIDE NOTE:
I was able to disable the banner "Microsoft Edge is being controlled by automated test software" using the switches below:
edge_options.add_experimental_option("useAutomationExtension", False)
edge_options.add_experimental_option("excludeSwitches", ['enable-automation'])
----------------------------------------
My system information
----------------------------------------
Platform: macOS
Python: 3.8.0
msedge-selenium-tools: 3.141.2
----------------------------------------