for (let n = 0; n < someNumber; n++){
try {
driver.get(url[n]);
driver.findElement(By.css("selector"));
} catch (err){
console.log(url[n] + "did not load");
}
}
I am trying to loop through web pages in Javascript. I am looking for an element on the page. If I cannot find the element, I want it to log the URL and continue the loop. The problem is that my code just stops at the findElement and will stop execution. It never reaches my catch block. I just get the error below:
NoSuchElementError: no such element: Unable to locate element: {"method":"css selector"
What am I doing wrong?