Prompt
how to fix popups breaking an unattended bot
Latest observation
Nov 6, 2026
OpenAI APIWeb search: off
To stop popups from breaking an unattended bot, the fix depends on whether you control the app/browser or only the bot. Here are the most effective approaches:
1) Prevent popups at the source
If possible, disable them in the application or browser:
- Turn off notifications, ads, tips, surveys, and update prompts
- Disable browser popups/notifications
- Use a clean test environment or bot account with fewer prompts
- Configure the app to skip onboarding/help dialogs
2) Make the bot detect and close popups
Add a popup-handling step before and during normal actions:
- Check for common modal/dialog selectors
- Look for “Close”, “Cancel”, “Not now”, “X” buttons
- Use text-based matching if selectors are inconsistent
- Retry the main action after dismissing the popup
Typical flow:
- Perform action
- If blocked, inspect for modal
- Close modal
- Continue
3) Use timeouts and recovery
Don’t let the bot hang indefinitely:
- Set short, explicit waits
- On timeout, dump screenshot/logs
- Refresh or restart the session if a popup can’t be dismissed
- Add a retry limit so the bot doesn’t loop forever
4) Run in a clean session
Popups often come from stale state:
- Clear cookies/cache/local storage
- Use a fresh profile/container per run
- Avoid reusing sessions with onboarding or consent banners
5) Handle browser/system-level popups separately
Some popups aren’t in the page DOM:
- OS dialogs: permission prompts, file download dialogs, auth prompts
- Browser alerts/confirm/prompt dialogs
- Native app windows
For these, your automation tool needs special handlers, e.g.:
- Browser alert handling
- UI automation tools for OS dialogs
- Pre-configured permissions to avoid prompts
6) Add a “popup watchdog”
A robust pattern is a background check that runs periodically:
- Detect overlays, modals, and unexpected focus changes
- Auto-dismiss known popups
- Escalate unknown ones with a screenshot and alert
7) Make the bot resilient
Good bot hygiene helps a lot:
- Use stable selectors, not fragile XPaths
- Prefer explicit conditions over fixed sleeps
- Verify page state before each critical step
- Log the popup text/class/name for later fixes
8) If using Selenium/Playwright
Common tactics:
- Selenium: handle JS alerts, look for modal elements, use waits, refresh if needed
- Playwright: listen for dialogs, close overlays, use locator checks, auto-waiting
Example recovery idea:
- Try action
- If blocked, close any visible dialog
- If still blocked, reload page and continue
- If repeated failure, mark the run failed and alert
If you want, I can give you a tool-specific solution for:
- Selenium
- Playwright
- Puppeteer
- Robot Framework
- Desktop automation (AutoIt, pywinauto, etc.)