Skip to content
3 changes: 2 additions & 1 deletion lib/web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,8 @@ export default class AutoConsent {
return selfTestResult;
}

async waitForPopup(cmp: AutoCMP, retries = 5, interval = 500): Promise<boolean> {
// TODO: use MutationObserver like in findCmp()
async waitForPopup(cmp: AutoCMP, retries = 10, interval = 500): Promise<boolean> {
Copy link

Copilot AI Jul 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The retry count increase from 5 to 10 lacks justification. Consider adding a comment explaining why shadowDOM requires more retries or making this configurable per CMP rather than a global change.

Suggested change
async waitForPopup(cmp: AutoCMP, retries = 10, interval = 500): Promise<boolean> {
/**
* Waits for a popup to appear for the given CMP. The retry count defaults to 10 to account for
* potential delays caused by shadow DOM or other asynchronous behaviors. This value can be
* overridden per CMP by setting a `retries` property on the CMP object.
*/
async waitForPopup(cmp: AutoCMP, retries = cmp.retries || 10, interval = 500): Promise<boolean> {

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@muodov did you mean to make this change?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sammacbeth yes, axeptio takes a long time to appear, and I've seen a few other CMPs do this as well. The detectPopup polling is much cheaper than detectCmp, so I thought it's okay to increase it.

const logsConfig = this.config.logs;
logsConfig.lifecycle && console.log('checking if popup is open...', cmp.name);
const isOpen = await cmp.detectPopup().catch((e) => {
Expand Down
38 changes: 27 additions & 11 deletions rules/autoconsent/axeptio.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,46 @@
{
"name": "axeptio",
"prehideSelectors": [".axeptio_widget"],
"prehideSelectors": [".axeptio_widget,.axeptio_mount"],
"detectCmp": [
{
"exists": ".axeptio_widget"
"exists": ".axeptio_widget,.axeptio_mount"
}
],
"detectPopup": [
{
"visible": ".axeptio_widget"
"any": [
{
"exists": ".axeptio-widget--open"
},
{
"visible": ".axeptio_mount .axeptio_widget"
},
{
"visible": [".axeptio_mount .needsclick", ".axeptio_widget"]
}
]
}
],
"optIn": [
{
"waitFor": ".axeptio-widget--open"
},
{
"click": "button#axeptio_btn_acceptAll"
"if": { "exists": ".axeptio_mount .needsclick" },
"then": [{ "click": [".axeptio_mount .needsclick", "button#axeptio_btn_acceptAll"] }],
"else": [{ "click": "button#axeptio_btn_acceptAll" }]
}
],
"optOut": [
{
"waitFor": ".axeptio-widget--open"
},
{
"click": "button#axeptio_btn_dismiss"
"if": { "exists": ".axeptio_mount .needsclick" },
"then": [
{ "waitForVisible": [".axeptio_mount .needsclick", "button#axeptio_btn_dismiss,button.ax-discardButton"] },
{ "wait": 300 },
{ "click": [".axeptio_mount .needsclick", "button#axeptio_btn_dismiss,button.ax-discardButton"] }
],
"else": [
{ "waitForVisible": "button#axeptio_btn_dismiss,button.ax-discardButton" },
{ "wait": 300 },
{ "click": "button#axeptio_btn_dismiss,button.ax-discardButton" }
]
}
],
"test": [
Expand Down
8 changes: 7 additions & 1 deletion tests/axeptio.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import generateCMPTests from '../playwright/runner';

generateCMPTests('axeptio', ['https://www.welcometothejungle.com/', 'https://frichti.co/landing?redirectTo=/', 'https://www.dorcel.com/']);
generateCMPTests('axeptio', [
'https://www.welcometothejungle.com/',
'https://www.dorcel.com/',
'https://mistral.ai/news/le-chat-dives-deep',
'https://lahalledesgourmets.com/pages/angelina',
'https://www.narbonneaccessoires.fr/fr-fr/',
]);