Currently, I am developing a function in JavaScript within the Selenium WebDriver framework to scroll on a website for a specific duration. The issue I am facing is that the default script timeout is approximately 15 seconds before it raises a ScriptTimeoutError. While there is ample information available on how to adjust this timeout in languages like Java with Selenium, documentation for the JS library is severely lacking.
To demonstrate the error, the test code below will trigger a ScriptTimeoutError after around 25 seconds:
const { Builder, By, Key } = require("selenium-webdriver");
async function example() {
let driver = await new Builder().forBrowser("chrome").build();
await driver.get("https://google.com");
await driver.executeScript(`
await new Promise((resolve) => setTimeout(resolve, 30000));
`);
console.log("DONE!");
}
example();
Below is the stack trace showing the ScriptTimeoutError:
ScriptTimeoutError: script timeout
(Session info: chrome=118.0.5993.118)
at Object.throwDecodedError (path\selenium-webdriver\lib\error.js:524:15)
at parseHttpResponse (path\selenium-webdriver\lib\http.js:601:13)
at Executor.execute (path\selenium-webdriver\lib\http.js:529:28)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Driver.execute (path\selenium-webdriver\lib\webdriver.js:745:17)
at async example (path\tests\test 4.js:8:3) {
remoteStacktrace: '\tGetHandleVerifier [0x00007FF705638EF2+54786]\n' +