admin管理员组文章数量:1432594
I have a Teams meeting bot using Puppeteer that works perfectly fine locally but fails when deployed to Kubernetes. The bot get stuck and can not click on the button even though it found that button.
Quesitons:
What could cause this behavior difference between local and Kubernetes environments?
Are there specific Puppeteer configurations needed for Kubernetes deployments?
Could this be related to network idle or page load states?
Code Structure:
class Task {
async initMeeting() {
const { meetingUrl, userName } = this.taskData;
await this.page.goto(meetingUrl, {
waitUntil: 'load',
timeout: 0,
});
await this.enterUserNameAndJoin(userName);
}
async ensurePageReloaded() {
await Promise.all([
this.page.reload(),
waitForNetworkIdle(this.page, 1_000, 2),
]);
}
async enterUserNameAndJoin(userName) {
const nameToType = `${userName}'s Assistant`;
const selector = '[data-tid="prejoin-display-name-input"]';
await this.page.waitForSelector(selector, {
visible: true,
timeout: 10000
});
await typeInput(this.page, {
value: nameToType,
dataTid: 'prejoin-display-name-input',
});
await this.page.waitForTimeout(1000);
await clickButton(this.page, { ariaLabel: 'Join now' });
}
}
My waitForNetWorkIdle
const waitForNetworkIdle = (page, timeout, maxInflightRequests = 0) => {
page.on('request', onRequestStarted);
page.on('requestfinished', onRequestFinished);
page.on('requestfailed', onRequestFinished);
let inflight = 0;
let fulfill;
let promise = new Promise((x) => (fulfill = x));
let timeoutId = setTimeout(onTimeoutDone, timeout);
return promise;
function onTimeoutDone() {
page.removeListener('request', onRequestStarted);
page.removeListener('requestfinished', onRequestFinished);
page.removeListener('requestfailed', onRequestFinished);
fulfill();
}
function onRequestStarted() {
++inflight;
if (inflight > maxInflightRequests) clearTimeout(timeoutId);
}
function onRequestFinished() {
if (inflight === 0) return;
--inflight;
if (inflight === maxInflightRequests)
timeoutId = setTimeout(onTimeoutDone, timeout);
}
};
What I've Tried:
Increased timeouts Added delays between actions Verified network connectivity Checked for element visibility
本文标签: nodejsPuppeteer bot works locally but fails to click button KubernetesStack Overflow
版权声明:本文标题:node.js - Puppeteer bot works locally but fails to click button Kubernetes - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745606310a2665858.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论