|
|
@@ -57,19 +57,34 @@ async function performLogin(page: Page, email: string, password: string): Promis
|
|
|
await page.waitForLoadState('domcontentloaded');
|
|
|
|
|
|
// Detect warm (password page shown immediately) vs cold (email input first).
|
|
|
- const flow = await Promise.race([
|
|
|
+ let flow: 'warm' | 'cold' | 'remembered' | null = await Promise.race([
|
|
|
page.waitForSelector('#password', { timeout: 15_000 }).then(() => 'warm' as const),
|
|
|
page.waitForSelector('#phone-or-email', { timeout: 15_000 }).then(() => 'cold' as const),
|
|
|
]).catch(() => null);
|
|
|
|
|
|
if (!flow) {
|
|
|
- loginDisabledReason = 'neither email input nor password field appeared on signup_login';
|
|
|
- throw new Error(`[airbnb] ${loginDisabledReason}`);
|
|
|
+ // Neither field appeared — check for the remembered-account screen: the device is
|
|
|
+ // recognized, so #phone-or-email is skipped entirely and the same submit button that
|
|
|
+ // the cold flow fills-then-clicks is shown ready to click immediately. Everything after
|
|
|
+ // the click is identical to the cold flow (Try another way → password option).
|
|
|
+ const submitBtn = page.locator('button[type="submit"]');
|
|
|
+ const remembered = await submitBtn.isVisible().catch(() => false)
|
|
|
+ && !(await page.locator('#phone-or-email').isVisible().catch(() => false));
|
|
|
+ if (remembered) {
|
|
|
+ flow = 'remembered';
|
|
|
+ } else {
|
|
|
+ loginDisabledReason = 'neither email input nor password field appeared on signup_login';
|
|
|
+ throw new Error(`[airbnb] ${loginDisabledReason}`);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- if (flow === 'cold') {
|
|
|
- console.error('[airbnb] Auto-login: cold session — filling email...');
|
|
|
- await page.locator('#phone-or-email').fill(email);
|
|
|
+ if (flow === 'cold' || flow === 'remembered') {
|
|
|
+ if (flow === 'cold') {
|
|
|
+ console.error('[airbnb] Auto-login: cold session — filling email...');
|
|
|
+ await page.locator('#phone-or-email').fill(email);
|
|
|
+ } else {
|
|
|
+ console.error('[airbnb] Auto-login: remembered-account session — skipping email entry...');
|
|
|
+ }
|
|
|
await page.locator('button[type="submit"]').click();
|
|
|
|
|
|
const tryAnother = page.getByRole('button', { name: /try another way/i });
|