Can't check if element is visible
See original GitHub issueThis element sometimes will be visible and sometimes won’t. I want to cheek if it’s visible in test, and if it’s visible I want to click on it.
The thing is that I don’t know if the element will be appear in the test.
It appears in some cases, and sometimes not, and the problem is that when I’m searching for it and it isn’t visible, the test fails.
I tried try/catch and it didn’t work.
I also tried if (cy.get('.text-center modal-header button[class="close"]').visible) cy.get('button[class="close"]').click();
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Check if element is visible in DOM - javascript - Stack Overflow
An element is counted as not being visible when it's not actually displayed on the screen. So if you scroll down and element...
Read more >How To Find Out if an Element is Hidden - W3Schools
To find out if an element is hidden with visibility:hidden , see the example below. This "hidden" element will take up space.
Read more >How to Check If Element is Hidden in Javascript - YouTube
In this video tutorial, you will learn how to check if element is hidden in javascript Source Code: ...
Read more >Interacting with Elements - Cypress Documentation
Cypress checks a lot of things to determine an element's visibility. The following calculations factor in CSS translations and transforms.
Read more >JavaScript: Check if Element is Hidden with jQuery
is(":visible") will test the visibility of an element and will return true if the selected element is visible, or it will return false...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Hi @KWorke,
since Cypress use the jQuery syntax for working with the DOM elements I would suggest you to try the following:
Please check the Conditional Testing Section for more information
Right, I forget that
wrapis the thing! Thx @brian-mann