How to automate dialogs

Dialogs tend to appear on websites when they wish to grab your attention, these often appear randomly or based on criteria that has been set by the page for marketing reasons.

# Standard alerts


By default, Axiom.ai will automatically dismiss most dialogs that are created using the standard alert() method. This was designed to prevent your automation from getting unexpectedly stuck when a dialog appears. This feature makes use of the following puppeteer script:

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

# Non-standard dialogs


Non-standard dialogs are not handled automatically - as the code that is used to build and manage these dialogs depends on the developers of the website, this means that the method of dismissing these can be a bit more involved.

To get started, you'll first need to identify the CSS selector of the 'accept' or 'dismiss' button on the dialog. This can be tricky as you'll need to ensure that you can get the dialog to appear. To learn more about finding the best selector, see our blog on the Best Custom CSS Selectors for Web Scraping.

💡 If you're struggling to get the dialog to appear, try opening the page in incognito mode. This ensures that any dialogs that may have it's 'dismiss' state stored in memory.

Once you have this selector, this can be added into a Click element step. This should be configured with the 'Optional click' option enabled, and the selector used within the step. You can learn more about using custom selectors in steps in the Custom CSS selectors documentation. This step should be added in the location where you most likely expect the dialog to display.