With GDPR Cookie consent banners/modals are a must-have for some stores, but they can often cause Robot Ninja tests to fail because they're covering an element we tried to click or send text to.

In this documentation will go over how to you can configure Robot Ninja to support cookie consent banners using custom selectors.

How to use custom selectors to handle cookie consent banners?

If you already have the CSS selector to handle the cookie consent banner/modal, jump to step 4.

1. Within Chrome, Firefox or Safari, go to any URL on your store which has the cookie consent banner

2. Right click on the button which accepts the cookie consent banner and click Inspect (screenshot below is using chrome). 

3. Find a CSS selector on the accept button. Look for unique ID or class attributes that aren't used for other elements on the page (ID="cookie_action_close_header").

4. Set the custom selector for "Close the cookie notice on store"  in Robot Ninja by going to Store > Settings > Selectors from the Dashboard.

5. Click the update button and queue up your tests again 🥳

Other helpful links


1. Will Robot Ninja test that the cookie consent is loading properly?

No, but we can write a custom test to check this.

Cookie consent notices vary from store-to-store and can be loaded differently and based on the test customers location and other factors.

Because of the number of variations, Robot Ninja will only look for the cookie notice and close them if they get in the way of clicking another element.

2. How do I tell if a pop up was blocking?


Robot Ninja records a screenshot on every failed test. This screenshot can be used to diagnose whether there was any floating elements covering the element Robot Ninja tried to interact with.

Error Message

If Robot Ninja's action was blocked because another element was covering the element they tried to interact with then the error message will usually say something like:

  • Robot Ninja could not fill in the X field because it was being covered by <Y>.
  • Robot Ninja was unable to click the element on the page. The element was being covered by <Y>.
Did this answer your question?