Close pop-ups and dialogs during an automation

How to close pop-ups and dialogs during an automation: install the Chrome extension, click Build with Browser agent, tell the agent what you want, and follow its prompts. A working bot is built and tested in minutes.

Here is how the automation works. To close pop-ups and dialogs during an automation, add a Click element step on the dialog's close or accept button, with Optional click turned on, where the dialog usually appears. Standard alert() dialogs need nothing: axiom.ai dismisses them for you. Websites show dialogs to catch your attention, often at random or on rules the site sets for marketing, so the automation here closes one and scrapes the page behind it.

Author
Alex Barlow
Published

Build closing the pop-up from a description


Describe it and click the button: the agent builds and tests the scraper in your Chrome extension.

  1. Go to the page I give you
  2. Close the pop-up if one appears
  3. Then scrape the title and price of every item
Click to launch the Chrome extension. Not installed? You can create an account and try it free.Opens the Chrome extension. Free account to try.

You need the URL of the page that shows the dialog.

Build closing the pop-up step by step


The steps the agent builds, as the Builder shows them: each step by its name, with the fields to set under it. Add them yourself in this order in the step-by-step builder, or open the agent's result there to adjust it.

  • 1.0 Go to page
    • URL: the page that shows the dialog
  • 2.0 Click element
    • Select: the dialog's accept or dismiss button, as a custom CSS selector
    • Optional click: on
  • 3.0 Get data from bot's current page
    • Select: the title and price of every item on the page, one column each

Common questions about closing pop-ups and dialogs


Do I need a step to close alert() dialogs?

No. axiom.ai dismisses most dialogs made with the standard alert() method by itself, with this Puppeteer script, so an automation does not get stuck when one appears:

page.on('dialog', async dialog => {
    await dialog.dismiss();
})

Dialogs a website builds itself are not handled for you. How each one is built and closed depends on the site's developers, so closing one takes a Click element step on its button.

Why does the dialog not appear when I look for its button?

The site has stored that you already closed it. Open the page in an incognito window, which starts without that stored state, and the dialog shows again.

What happens when the dialog does not appear during a run?

With Optional click turned on, nothing: the step waits up to 10 seconds for the dialog, which you can change in the box beside the switch, then the automation continues without an error. Without it, Click element fails because the button is not on the page.

Why does the automation still stop at the dialog?

The click runs before the dialog appears, or the selector does not match its button. Move the Click element step to where the dialog shows, add a Wait step before it, or reselect the button. When a run fails, hand it to the agent and it repairs the step.

Yes. A cookie banner is a dialog the website builds itself, so the same optional Click element on its accept or dismiss button closes it, placed right after the Go to page step that opens the site.

Does it work on any website?

Yes. Every site builds its dialogs its own way, so the selector of the button differs from site to site, but the shape is the same: one optional Click element where the dialog appears, then the steps that do the work.

Where do I get help?

Get in touch with support, or ask in the axiom.ai community.

Related guides