I am working with Puppeteer to automate a website that includes a search form which can return either a valid result or a message indicating that no records were found. What’s the best approach to identify what has been returned? It appears that waitForSelector can only handle one selector at a time, and waitForNavigation doesn’t function as expected since the response is delivered via Ajax. I’ve tried using a try-catch structure, but it complicates the process and slows down execution significantly.
try {
await page.waitForSelector(SELECTOR_A, {timeout: 1000});
} catch(error) {
await page.waitForSelector(SELECTOR_B);
}