selenium How to dismiss a chrome popup

Viewed 231

scrshot I tried anything I could find on this but I can't get selenium to dismiss this alert. I don't think it's an alert anymore though, as I get NoAlertPresentException when I try

driver.switch_to.alert.dismiss()

Any ideas?

Here are relevant parts of the HTML page:

<iframe id="teamsLauncher" src="msteams:/l/team/19:95f3ef22a37040fca83b679b64f96da1@thread.tacv2/conversations?groupId=09988212-e3a1-4187-b067-a805e512e0a4&amp;tenantId=d348f9ab-4879-4a60-ab50-5c420b11470c&amp;deeplinkId=2deee564-c6b3-4d5d-b097-93900dd14620&amp;launchAgent=join_launcher&amp;type=team&amp;directDl=true&amp;msLaunch=true&amp;enableMobilePage=true&amp;fqdn=teams.microsoft.com" style="display: none;"></iframe>
<script>var modernBrowser="fetch"in window&&"assign"in Object&&"Set"in window,bundles=[],polyfills="";function injectScript(n,e,s){var t=document.createElement("script");t.src=n,t.async=e,t.onload=s,document.body.appendChild(t)}function loadBundles(n){for(key in bundles)injectScript(bundles[key],n)}function loadPolyfills(){polyfills&&injectScript(polyfills,!1,function(){loadBundles(!1)})}bundles.push("https://statics.teams.microsoft.com/hashedjs-launcher/launcher.5c24f1e70f34f56835c7.js"),polyfills="https://statics.teams.microsoft.com/hashedjs-launcher/polyfills.1e46ca6473519cf1be5d.js",modernBrowser?loadBundles(!0):loadPolyfills(),window.addEventListener("load",function(){injectScript("https://az725175.vo.msecnd.net/scripts/jsll-4.js",!0,function(){var n={coreData:{appId:"JS:teams.microsoft.com",market:window.navigator.language||"en-US"}};awa&&awa.init&&awa.init(n)})})</script>

Also tried actionchains, but sending escape key doesn't do anything.

2 Answers

Hard to say without running the code, but maybe try disabling chrome popups with Chrome Options?

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--disable-notifications")
driver = webdriver.Chrome(options=chrome_options)

I hope, this works.

Consider using the library pyAutoGUI, it allows python to control your mouse and keyboard. If you keep the window in the same place each time, a static x y coordinate for the mouse click function can be used to accept the popup and allow you to procced

Related