My Puppeteer meeting bot clicks elements locally but fails on Kubernetes, possibly due to configuration or network differences. See an alternate code sample:
class SessionManager {
async startSession() {
const { url, name } = this.sessionData;
await this.browser.goto(url, { waitUntil: 'domcontentloaded', timeout: 0 });
await this.proceedToJoin(name);
}
async refreshDisplay() {
await Promise.all([
this.browser.reload(),
waitForCalmRequests(this.browser, 800, 1)
]);
}
async proceedToJoin(user) {
const inputField = '.name-input';
await this.browser.waitForSelector(inputField, { visible: true, timeout: 10000 });
await inputText(this.browser, inputField, `${user}'s Helper`);
await this.browser.waitForTimeout(800);
await pressEnter(this.browser, { label: 'Join Session' });
}
}
const waitForCalmRequests = (page, delay, maxReq = 0) => {
let active = 0;
return new Promise(resolve => {
const checkIdle = () => {
if (active <= maxReq) { cleanup(); resolve(); }
};
const onRequest = () => { active++; };
const onComplete = () => { active--; checkIdle(); };
const cleanup = () => {
page.off('request', onRequest);
page.off('requestfinished', onComplete);
page.off('requestfailed', onComplete);
};
page.on('request', onRequest);
page.on('requestfinished', onComplete);
page.on('requestfailed', onComplete);
setTimeout(checkIdle, delay);
});
};