I'm building a Selenium Grid systems in Kubernetes with Chrome and Firefox nodes and a hub.
The tests goes well with 3 times invoke or 6 sessions in queue. But when it goes higher, the console will return a 504 error. Here is the code:
let driver = new Builder()
.usingServer("https://example.com/")
.withCapabilities(capabilities)
.setChromeOptions(chromeOptions)
.build();
try {
console.log("Execution Start..............", Date());
await driver.get('http://www.google.com');
console.log("After get..............", Date());
// Enter text "cheese" and perform keyboard action "Enter"
await driver.findElement(By.name('q')).sendKeys('tester', Key.ENTER);
console.log("After findElement..............", Date());
let firstResult = await driver.wait(until.elementLocated(By.css('h3')), 10000);
console.log("Before firstResult..............", Date());
console.log(await firstResult.getAttribute('textContent'));
console.log("After firstResult..............", Date());
} finally {
console.log("Execution end..............", Date());
await driver.quit();
}
}
And here is the output:
Execution end.............. Sun Dec 19 2021 19:39:11 GMT+0700 (Indochina Time)
(node:96313) UnhandledPromiseRejectionWarning: WebDriverError: <html>
<head><title>504 Gateway Time-out</title></head>
<body>
<center><h1>504 Gateway Time-out</h1></center>
<hr><center>nginx</center>
</body>
</html>
at parseHttpResponse (/SeleniumGrid/node_modules/selenium-webdriver/lib/http.js:664:11)
at Executor.execute (/SeleniumGrid/node_modules/selenium-webdriver/lib/http.js:573:28)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:96313) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 6)
(node:96313) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:96313) UnhandledPromiseRejectionWarning: WebDriverError: <html>
<head><title>504 Gateway Time-out</title></head>
<body>
<center><h1>504 Gateway Time-out</h1></center>
<hr><center>nginx</center>
</body>
</html>
at parseHttpResponse (/SeleniumGrid/node_modules/selenium-webdriver/lib/http.js:664:11)
at Executor.execute (/SeleniumGrid/node_modules/selenium-webdriver/lib/http.js:573:28)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
(node:96313) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 8)
I think the error appear and the await driver.get('http://www.google.com');
line. Does anyone know how to fix it?