fix(myTischtennis): ensure login intent handling and improve form submission logic
- Added logic to ensure the presence of a login intent field in the login form, enhancing the reliability of the login process. - Updated the form submission mechanism to prioritize the explicit login submit button, falling back to a generic submit button if necessary. - Improved overall interaction flow during the login process, ensuring a smoother user experience.
This commit is contained in:
@@ -536,10 +536,27 @@ class MyTischtennisClient {
|
||||
console.log('[myTischtennisClient.playwright] Waited after solved captcha:', postCaptchaDelayMs);
|
||||
}
|
||||
|
||||
// Ensure login intent is present and click the explicit login submit button.
|
||||
await page.evaluate(() => {
|
||||
const form = document.querySelector('form[action*="/login"]');
|
||||
if (!form) return;
|
||||
let intentField = form.querySelector('input[name="intent"]');
|
||||
if (!intentField) {
|
||||
intentField = document.createElement('input');
|
||||
intentField.setAttribute('type', 'hidden');
|
||||
intentField.setAttribute('name', 'intent');
|
||||
form.appendChild(intentField);
|
||||
}
|
||||
intentField.setAttribute('value', 'login');
|
||||
});
|
||||
|
||||
// Submit form
|
||||
const submitButton = page.locator('button[type="submit"], input[type="submit"]').first();
|
||||
if (await submitButton.count()) {
|
||||
await submitButton.click({ timeout: 15000, noWaitAfter: true });
|
||||
const loginSubmitButton = page.locator('button[type="submit"][name="intent"][value="login"]').first();
|
||||
const genericSubmitButton = page.locator('button[type="submit"], input[type="submit"]').first();
|
||||
if (await loginSubmitButton.count()) {
|
||||
await loginSubmitButton.click({ timeout: 15000, noWaitAfter: true });
|
||||
} else if (await genericSubmitButton.count()) {
|
||||
await genericSubmitButton.click({ timeout: 15000, noWaitAfter: true });
|
||||
} else {
|
||||
await page.keyboard.press('Enter');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user