How to handle cookie banners
Cookie banners often appear the first time that you enter a website, or when your browser cache has been cleared. These may appear when running your Axiom.ai automations, specifically if you haven't visited the site before, or you are running on our Cloud infrastructure. There are multiple methods of handling these banners.
These steps should be added to your automation after the "Go to page" step but before any other steps. If a cookie banner appears at different times during the navigation of the website, you may need to add these elsewhere within your automation to prevent errors.
# Checking if the banner is present before clicking
One method is checking if the cookie banner is present on the page, and if it is, using the Click element step to click the "accept" or "decline" buttons, or a more complex set of steps, if you wish. Check out our How to check if an element exists and proceed conditionally guide for tips on how to do this.
# Clicking and catching the error
Another method may be to attempt to click the "accept" or "decline" buttons without checking if the cookie banner is present. This will cause an error when the banner is not present that can be caught using the Try/Catch step and allow your automation to continue running as expected. To do so, follow the steps below:
- Add a "Try/catch" step.
- In the "try" section, add a "Click element" step that clicks "accept" or "reject".
- Leave the "catch" section empty.
Continue building your automation as normal after the "Try/catch" step. You can learn more about this step in our Getting to Know the Try/Catch Step - Tips and Tricks blog article.
# FAQ
# Unable to see cookie banner when building automation
If you are not seeing the cookie banner while building your automation it's likely that you have already interacted with it in the past - most websites will not show this during every visit. There are a few methods of getting the cookie banner to show when you have previously accepted/declined the site's cookies:
- (recommended) Use incognito mode on your browser to build your automation - you will need to allow Axiom.ai to operate in incognito by navigating to chrome://extensions → "Details" under the "Axiom" extension → enable "Allow in incognito".
- Clear your cookies - navigate to chrome://settings/clearBrowserData → select "Cookies and other site data" → select "Delete data".
Both methods will allow the cookie banner to show again. Note, the second method will cause the cookies to be removed for all sites - meaning that this can cause the cookie banners from other sites you visit to reappear.
# Cookie banners appearing when they were not previously
As part of our migration to our new, improved infrastructure you may see additional cookie banners that were not previously showing when you run your automations. This migration will lay the foundation for further improvements coming down the pipeline. You can learn more about what we are working on over on our "New Axiom" page.
Have any questions? Let us know over in our community (opens new window)