Improve the UI and tests
This commit is contained in:
@@ -153,3 +153,25 @@ export async function isVisible(page: Page, selector: string): Promise<boolean>
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Accepts cookie consent dialog if present
|
||||
* Should be called after navigating to a page
|
||||
*/
|
||||
export async function acceptCookieConsent(page: Page) {
|
||||
try {
|
||||
const acceptButton = page.getByRole('button', {
|
||||
name: /aceptar todas|accept all/i,
|
||||
});
|
||||
|
||||
const isVisible = await acceptButton.isVisible({ timeout: 2000 }).catch(() => false);
|
||||
|
||||
if (isVisible) {
|
||||
await acceptButton.click();
|
||||
// Wait a bit for the dialog to close
|
||||
await page.waitForTimeout(500);
|
||||
}
|
||||
} catch (error) {
|
||||
// Cookie dialog not present, that's fine
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user