Update
This commit is contained in:
1 parent
0158103f64
commit
2cf474899c
1 file changed
+35
-2
+35
-2
@@ -96,6 +96,21 @@ export class BrowserClient {
|
||||
// Navigate to login page
|
||||
await page.goto('https://www.reddit.com/login', { waitUntil: 'domcontentloaded' });
|
||||
|
||||
// Dismiss common consent dialogs if present
|
||||
const consentSelectors = [
|
||||
'button:has-text("Accept")',
|
||||
'button:has-text("I Accept")',
|
||||
'button:has-text("Allow all")',
|
||||
'button:has-text("OK")',
|
||||
];
|
||||
for (const selector of consentSelectors) {
|
||||
const button = page.locator(selector).first();
|
||||
if (await button.isVisible().catch(() => false)) {
|
||||
await button.click().catch(() => undefined);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Wait for inputs
|
||||
// Reddit uses various IDs but name="username" and name="password" are reliable
|
||||
this.logger.debug('Waiting for login form...');
|
||||
@@ -110,8 +125,26 @@ export class BrowserClient {
|
||||
await page.fill('input[name="password"]', this.config.reddit.password);
|
||||
|
||||
// Click login button
|
||||
// Look for a button with type="submit" or text containing "Log In"
|
||||
await page.click('button[type="submit"]'); // Standard form submit
|
||||
// Look for a submit button or a "Log In" button
|
||||
const submitSelectors = [
|
||||
'button[type="submit"]',
|
||||
'button:has-text("Log In")',
|
||||
'button:has-text("Log in")',
|
||||
'[role="button"]:has-text("Log In")',
|
||||
'[role="button"]:has-text("Log in")',
|
||||
];
|
||||
let clicked = false;
|
||||
for (const selector of submitSelectors) {
|
||||
const button = page.locator(selector).first();
|
||||
if (await button.isVisible().catch(() => false)) {
|
||||
await button.click();
|
||||
clicked = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!clicked) {
|
||||
throw new Error('Login failed: Could not find a visible submit button');
|
||||
}
|
||||
|
||||
this.logger.info('Credentials submitted. Waiting for navigation...');
|
||||
|
||||
|
||||
Reference in new issue
Block a user