What I want to do is everytime I get a no provider error is to redo the check and get the new Provider's section. So what I want to is encase a Promise inside a loop and then either leave when no provider works or leave when there are no errors on the page.
As I am unsure of how to use Promises inside loops I'm not sure where to go from this.
await driver.wait(until.elementLocated(By.xpath(path)), 5000, 'Timed out after 5 seconds', 500).then(found => {
console.log("Found no provider error");
// click back goes to same page different section
// click new index for dropdown
// return if index is not valid
// then click next to go back to same section.
}, error => {
console.log("Didn't find no provider error")
});
I tried using the following
retry(_ =>
driver.wait(until.elementLocated(By.xpath(path)),5000)
.then(found => {
console.log("Provider error");
throw Error("Provider error");
}, error=>{
console.log("Didn't find no provider error");
return;
})
, providerDropDownCount
)
.then(result =>console.log(result))
.catch(err => console.error("Failed after ", err))
Which leads to no repeats.
Provider error
Failed after Error: Provider error
at C:\Users\arund\Desktop\Code\Python\Selenium\Porton\bookApp\index.js:255:23
at processTicksAndRejections (node:internal/process/task_queues:93:5)
at async retry (C:\Users\arund\Desktop\Code\Python\Selenium\Porton\bookApp\index.js:221:14)