pyppeteer_stealth icon indicating copy to clipboard operation
pyppeteer_stealth copied to clipboard

Alert Dialog Unable to SwitchTo and Accept / Dissmiss

Open dev-bot-team opened this issue 1 year ago • 1 comments

I want to dismiss 'Cancel' popup Dialog or I don't know if it is Alert box whatever but since it doesn't work I want to ask if anyone know the solution. 1. I login to my spotify and I wish to create playlist but right after I sign in and open.spotify is loaded the website shows this annoying Dialog see image: Screenshot 2023-03-03 004905 2. I have tries this code to put BEFORE the URL opens which cause totally browser close and if AFTER the url open and shows the alert box dialog it does nothing at all !

CODE:

context = await browser.createIncognitoBrowserContext()
page = await context.newPage()
await stealth(page)

page.on('dialog', lambda dialog: asyncio.ensure_future(close_dialog(dialog)))
await page.evaluate('() => alert("1")') 
await page.goto('https://open.spotify.com/',  {'waitUntil' : 'domcontentloaded'})

SO IF page.on IS BEFORE the URL it will close the all browser NOT only that Dialog if it is AFTER it does nothing.

Any senior developer can help on this? Appreciate much !

PS: I use my own path to real Brave browser btw and I also tries to not allow notifications, I uninstalled spotify app from windows, I tried to block popup using different chrome extensions, NOTHING is working!

dev-bot-team avatar Mar 03 '23 00:03 dev-bot-team

Maybe try setting up request interception to block the popup dialog?

gbiz123 avatar May 07 '23 21:05 gbiz123