I am using the Puppeteer automation library and need to ensure that my script interacts with elements only after they are visibly rendered. For example, I want to perform a click on a button only once it becomes visible on the page. I attempted to use a helper function, similar to the example below, but it didn’t function as expected:
const checkbox = await page.$('input[data-check="confirm"]');
await checkbox.click();
// Intend to wait until the nextButton is displayed
await waitForVisibility('.nextButton');
const nextButton = await page.$('.nextButton');
await nextButton.click();
Could someone provide guidance or alternate methods to reliably wait for an element to be visible before proceeding with further actions?