Using puppeteer, i open up a page when i enter a value - it outputs the result.
await page.click('button[class="button form-button rs-gcbalance-btn"]')
await page.waitForSelector('div[class="small-4 large-4 rs-gcbalance-result-num-col').catch(err => console.log(err))
await page.evaluate((card) => {
console.log(card + " - " + document.querySelectorAll('div[class="small-4 large-4 rs-gcbalance-result-num-col"]')[1].querySelector('span').innerHTML)
}, card)
But that works correctly only if the value on enter is valid. If it's not, it would throw an error, but without any network activity or load event.
That means, that if the value is incorrect, the element i'm waiting for won't appear and will throw an error, closing the program.
Navigation Timeout Exceeded: 30000ms exceeded
The question is: how to handle the error, so if it throw a timeout error, i can catch it and call another function?
from Puppeteer page.waitForNavigation() timeout error handling
No comments:
Post a Comment