Search code examples
scalabilityplaywright

Playwright: Will it find overlapped elements


I was wondering (have not tested it myself) if Playwright is able to find - for example - a button and click it when it is being overlapped by another button. Or if there is a way to check if an element is more than - for example - 50% visible.

I've read the documentation on Auto-waiting but noticed that it didn't say anything about this phenomenon. isVisible() clearly states the following:

Element is considered visible when it has non-empty bounding box and does not have visibility:hidden computed style. Note that elements of zero size or with display:none are not considered visible.

And thus doesn't say anything about it actually being visible - in the sense of 'on the fore-ground' - to the end-user.

Does anyone know if this is correct or if there is a way to actually test this?

Purely wondering for scalability purposes.


Solution

  • If there is an element on top of the target element, you will get a timeout saying that X element intercepts pointer events, and it will fail.

    I think (I'm not 100% sure) that Playwright will only try to click at the center of the element.