I'm trying to simulate clicking on an element that is rendered after a certain iteration of document.readyState='complete'. To get around the readyState issue, I thought of try-catching the executeScript command to just make it retry until it works.
But for some reason Node / Selenium just stops working entirely from the resulting Js error:
Cannot read properties of undefined (reading 'parentElement')
Any ideas on how I should solve this? Here's part of my code. It'll open up the supplied url (item) and should execute the command as soon as the element icon-download is rendered.
async function getFileFromUrl(item) {
var command = "document.getElementsByClassName('icon-download')[0].parentElement.click()";
driver.get(item);
do {
await delay(500);
try{
driver.executeScript(command);
} catch (e) {
continue;
}
break;
} while (true);
await delay(3000);
}
Ok so I managed to fix it by prefixing the driver-commands with Await. If they return an exception it's recognized by Node now. Code below:
async function getFileFromUrl(item) {
var command = "document.getElementsByClassName('icon-fpk icon-download-xls')[0].parentElement.click()";
await driver.get(item);
do {
await delay(500);
try{
await driver.executeScript(command);
} catch {
continue;
}
break;
} while (true);
await delay(3500);
}
Firebase Cloud Functions: PubSub, "res.on is not a function"
TypeError: Cannot read properties of undefined (reading 'createMessageComponentCollector')
so I need to download a file from S3 bucket and then, with either its buffer or readStream, append it to a FormData on nodeI've tried different libraries such as formdata-node, isomorphic-form-data and form-data
my nodejs module starts a server on a specific port, I am wondering if it is a way to stop the execution of that server in my mocha test:
I need to executemjs script about 200 times with another parameters (changableParametr):
I'm having an async problem, and I've followed a lot of articles online to try and get this issue fixed, but it hasn't done anything