Füge Unterstützung für das Akzeptieren von Cookie-Zustimmungen hinzu: Implementiere eine Funktion, die verschiedene Consent-Dialoge automatisch akzeptiert.
All checks were successful
Code Analysis and Production Deploy / analyze (push) Successful in 4m50s
Code Analysis and Production Deploy / deploy-production (push) Has been skipped
Code Analysis and Production Deploy / deploy-test (push) Successful in 2m42s

This commit is contained in:
Torsten Schulz (local)
2026-09-04 15:43:11 +02:00
parent ee93e15af8
commit 02c1765214

View File

@@ -34,13 +34,29 @@ async function loginDirect(email, password) {
}
async function loginWithBrowser(email, password) {
const browser = await chromium.launch({ headless: true })
const browser = await chromium.launch({ headless: true, args: ['--disable-dev-shm-usage'] })
try {
const page = await browser.newPage()
// Das myTT-CAPTCHA wird erst nach dem Laden der Seite erzeugt. Der Ablauf
// entspricht der erprobten Integration im Trainingstagebuch.
const acceptConsentDialog = async (waitMs = 0) => {
if (waitMs) await page.waitForTimeout(waitMs)
for (const selector of [
'#onetrust-accept-btn-handler', 'button:has-text("Alle akzeptieren")',
'button:has-text("Akzeptieren")', 'button:has-text("Einverstanden")',
'button:has-text("Zustimmen")', '[data-testid="accept-button"]', '.cmp-accept-all', '.accept-all-btn'
]) {
try {
const button = page.locator(selector).first()
if (await button.count()) { await button.click({ timeout: 2_500 }); await page.waitForTimeout(800); return true }
} catch { /* try next CMP selector */ }
}
return false
}
await page.goto(BASE_URL, { waitUntil: 'domcontentloaded', timeout: 30_000 }).catch(() => {})
if (!await acceptConsentDialog()) await acceptConsentDialog(2_500)
await page.goto(`${BASE_URL}/login?next=%2F`, { waitUntil: 'domcontentloaded', timeout: 45_000 })
if (!await acceptConsentDialog()) await acceptConsentDialog(1_500)
await page.locator('input[name="email"]').fill(email)
await page.locator('input[name="password"]').fill(password)