When attempting to click on various elements within a page, my goal is to do so only if they are visible. While achieving this in selenium with the is_displayed
method was simple, I have struggled to find a similar approach in puppeteer.
I attempted to implement something along these lines:
try {
await page
.waitForSelector(id, visible=true, timeout=0)
.then(() => {
element.click()
});
...
Unfortunately, this approach does not work as expected with simple elements like :
<a class="cookie-close" href="#">
OK
</a>
Additionally, I have been unable to determine how to achieve this using the element.click
method in puppeteer.