Open utterances-bot opened 1 year ago
To check if an element is in the viewport in Cypress, we can add a custom 'inViewport' assertion to Chai using the support folder.
https://www.webtips.dev/webtips/cypress/check-if-element-is-in-viewport?utterances=eb663369dcfd1ad78f89f9e1VmVHPDPzhWrzMgDos1HC7IqgeYuhp1J16z64EbMskY5%2BUVN%2F7Ohyp2Nnx14BwV9bG%2Bsatto2df4mU0OtzxnVJafiV0FOxX6QSiKzd6sYECPQbNhL7L3heeGSlss%3D
Note that the standard is.visible assertion might be all you need.
is.visible
There is a slight bug in your code here, you also need to check that the element is not out the top, with && rect.bottom >= 0
&& rect.bottom >= 0
How to Check if Element is in Viewport in Cypress - Webtips
To check if an element is in the viewport in Cypress, we can add a custom 'inViewport' assertion to Chai using the support folder.
https://www.webtips.dev/webtips/cypress/check-if-element-is-in-viewport?utterances=eb663369dcfd1ad78f89f9e1VmVHPDPzhWrzMgDos1HC7IqgeYuhp1J16z64EbMskY5%2BUVN%2F7Ohyp2Nnx14BwV9bG%2Bsatto2df4mU0OtzxnVJafiV0FOxX6QSiKzd6sYECPQbNhL7L3heeGSlss%3D