MeiK2333 / pyppeteer_stealth

MIT License
245 stars 53 forks source link

Alert Dialog Unable to SwitchTo and Accept / Dissmiss #31

Open dev-bot-team opened 1 year ago

dev-bot-team commented 1 year ago

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.spotifyis loaded the website shows this annoying Dialog see image: Screenshot 2023-03-03 004905

  1. 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 IFpage.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!

gbiz123 commented 1 year ago

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