pythonselenium-webdriver

How can I automatically dismiss the "Open Microsoft Teams?" browser pop-up in Selenium?


https://teams.microsoft.com/dl/launcher/launcher.html?url=%2F_%23%2Fl%2Fmeetup-join%2F19%3Ameeting_YjdjZDdiNTAtYzk0Ny00NjQ5LThjYjUtZDdhNTgxZmJkNzFk%40thread.v2%2F0%3Fcontext%3D%257b%2522Tid%2522%253a%2522ad41d6c3-67f0-47cc-9de3-e07fd185c1c7%2522%252c%2522Oid%2522%253a%2522231785c4-849f-4137-814a-3eda9145fef2%2522%257d%26launchApp%3Dfalse%26anon%3Dtrue&type=meetup-join&deeplinkId=cb39187c-361f-4eb5-b28a-a2084325f1ff&directDl=true&msLaunch=true&enableMobilePage=true&suppressPrompt=true

I'm automating a flow that involves joining a Microsoft Teams meeting using Selenium. When navigating to the meeting URL, a browser pop-up appears asking: to open in desktop or Cancel. i want to ignore this pop up in selenium python. I've tried setting Chrome preferences like:

    # Supress popup requests for notifications that disturb flows, allow use microphone and camera devices
    options.add_experimental_option("prefs", {"profile.default_content_setting_values.notifications": 2,
                                              'profile.default_content_setting_values.media_stream_mic': 1,
                                              'profile.default_content_setting_values.media_stream_camera': 1,
                                              'profile.default_content_setting_values.popups': 2,
                                              "protocol_handler.excluded_schemes": {
                                                  "msteams": True}  # block attempts to open Teams locally
                                              })

But the pop-up still appears and blocks the automation. Since this is a browser-level prompt (not part of the DOM), Selenium can't interact with it directly.

I also tried to add this to the url.

url = self.teams_meeting['joinWebUrl'] +'&launchApp=false'

Is there a way to suppress or auto-dismiss this pop-up using Chrome options,or any other workaround?

Attached img of the popup. enter image description here


Solution

  • My solution is to press Enter, which cancels the popup.

    import pyautogui
    pyautogui.press('enter')