fix: wait up to 20s for 'Sign in' link on pre-join page (was only checking once after 3s)
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
b07910410e
commit
121c70e60a
1 changed files with 36 additions and 34 deletions
|
|
@ -147,45 +147,42 @@ export class BotOrchestrator {
|
||||||
// anonymous pre-join page. Clicking it triggers the Microsoft login flow,
|
// anonymous pre-join page. Clicking it triggers the Microsoft login flow,
|
||||||
// which redirects back to an authenticated pre-join page within Teams v2.
|
// which redirects back to an authenticated pre-join page within Teams v2.
|
||||||
if (authenticate) {
|
if (authenticate) {
|
||||||
this._logger.info('Authenticated join: looking for "Sign in" link on pre-join page...');
|
this._logger.info('Authenticated join: waiting for pre-join page to load, then clicking "Sign in"...');
|
||||||
|
|
||||||
// Wait for the pre-join page to load
|
// Wait for the pre-join page to fully load.
|
||||||
await this._page!.waitForTimeout(3000);
|
// After "Continue on this browser", Teams loads the light-meetings pre-join page.
|
||||||
|
// This can take 5-15 seconds and may show mic/camera permission overlays.
|
||||||
// Dismiss mic/camera permission overlay if present
|
// The "Sign in" link appears at the bottom of the page once it's loaded.
|
||||||
// The "Continue without audio or video" modal may appear here
|
|
||||||
await this._joinProcedure.dismissBrowserPermissionModals();
|
|
||||||
|
|
||||||
// Find and click the "Sign in" link at the bottom of the pre-join page
|
|
||||||
const signInSelectors = [
|
|
||||||
'a:has-text("Sign in")',
|
|
||||||
'button:has-text("Sign in")',
|
|
||||||
'a:has-text("Anmelden")',
|
|
||||||
'button:has-text("Anmelden")',
|
|
||||||
'a[href*="login"]',
|
|
||||||
];
|
|
||||||
|
|
||||||
|
// Wait for "Sign in" link to appear (up to 20 seconds)
|
||||||
let signInClicked = false;
|
let signInClicked = false;
|
||||||
for (const sel of signInSelectors) {
|
const signInSelector = 'a:has-text("Sign in"), button:has-text("Sign in"), a:has-text("Anmelden"), button:has-text("Anmelden")';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const link = await this._page!.$(sel);
|
this._logger.info('Waiting for "Sign in" link to appear on pre-join page...');
|
||||||
if (link) {
|
await this._page!.waitForSelector(signInSelector, { timeout: 20000, state: 'visible' });
|
||||||
await link.click();
|
|
||||||
this._logger.info(`Clicked "Sign in" link: ${sel}`);
|
// Click it
|
||||||
|
const signInLink = await this._page!.$(signInSelector);
|
||||||
|
if (signInLink) {
|
||||||
|
await signInLink.click();
|
||||||
|
this._logger.info('Clicked "Sign in" link on pre-join page');
|
||||||
signInClicked = true;
|
signInClicked = true;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
} catch { /* continue */ }
|
} catch {
|
||||||
|
this._logger.info('"Sign in" not found via waitForSelector, trying DOM scan...');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fallback: scan DOM for sign-in link
|
||||||
if (!signInClicked) {
|
if (!signInClicked) {
|
||||||
// Fallback: try to find "Sign in" by evaluating text content
|
// The page might have loaded but the selector didn't match exactly
|
||||||
signInClicked = await this._page!.evaluate(() => {
|
signInClicked = await this._page!.evaluate(() => {
|
||||||
const links = document.querySelectorAll('a, button');
|
// Look for any link/button with "Sign in" or "Anmelden" text
|
||||||
for (let i = 0; i < links.length; i++) {
|
const allElements = document.querySelectorAll('a, button, span[role="link"]');
|
||||||
const el = links[i] as HTMLElement;
|
for (let i = 0; i < allElements.length; i++) {
|
||||||
const text = el.innerText?.trim().toLowerCase() || '';
|
const el = allElements[i] as HTMLElement;
|
||||||
if (text === 'sign in' || text === 'anmelden') {
|
const text = el.innerText?.trim() || '';
|
||||||
|
if (text === 'Sign in' || text === 'Anmelden') {
|
||||||
el.click();
|
el.click();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -193,7 +190,12 @@ export class BotOrchestrator {
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
if (signInClicked) {
|
if (signInClicked) {
|
||||||
this._logger.info('Clicked "Sign in" via DOM evaluation');
|
this._logger.info('Clicked "Sign in" via DOM evaluation fallback');
|
||||||
|
} else {
|
||||||
|
this._logger.warn('Could not find "Sign in" link on pre-join page');
|
||||||
|
// Log page content for debugging
|
||||||
|
const pageText = await this._page!.evaluate(() => document.body?.innerText?.substring(0, 500) || '');
|
||||||
|
this._logger.warn(`Pre-join page content: ${pageText.substring(0, 300)}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue