Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webtips/cypress/check-if-element-is-in-viewport #19

Open
utterances-bot opened this issue Sep 27, 2022 · 2 comments
Open

webtips/cypress/check-if-element-is-in-viewport #19

utterances-bot opened this issue Sep 27, 2022 · 2 comments

Comments

@utterances-bot
Copy link

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

Copy link

Note that the standard is.visible assertion might be all you need.

Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants