-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Elements hidden using clip / clip-path css properties pass as visible #1178
Comments
Our calculations for visibility can be found here if anyone wants to contribute: https://github.com/cypress-io/cypress/blob/develop/packages/driver/src/dom/visibility.js |
The original test chainers were written incorrectly in the original comment, but nonetheless this is an error demonstrated below. You can clearly not see the elements on the page, but Cypress passes saying they are visible and fails when asserting they are not visible. index.html<html>
<body>
<div style="position: absolute; clip: rect(1px, 1px, 1px, 1px);">
<span id="clip">clip</span>
</div>
<div style="position: absolute; clip-path: polygon(0 0, 0 0, 0 0, 0 0);">
<span id="clip-path">clip-path</span>
</div>
</body>
</html> spec fileit('should not be visible', () => {
cy.visit('index.html')
cy.get('#clip').should('not.be.visible') // fails but should pass
})
it('should not be visible', () => {
cy.visit('index.html')
cy.get('#clip-path').should('not.be.visible') // fails but should pass
})
|
* Add failing test case for visible element within overflow hidden then position absolute element. Addresses #4395 * Write failing test case for when parent is flex and overflow hidden with el outside bounds Addresses #4161 * Wrote failing test for visibility outside of clip-path Addresses #1178 * Add failing tests for transform scale Addresses #723 * Add failing test for backfact-visibility hidden example * cs -> js fixes * Add more specific error when el is not element * Always return as visible when checking html or body * Add comments + rename methods to be more exact * Add case for isHidden when visibility is collapse * Add failing test cases for visibility issues * Add comment about how ensureVisibility works under the hood * Add checks and tests for opacity: 0 to be hidden * Simplify if/case statements to be more readable * Expand check for offset parents to also check children of ancestor for positioning attributes close #4395 close #755 * Fix issue where els with parents with absolute position inside overflow hidden would be calculated as not visible * comment out opacity checks for patch release * Add more tests around new visibility assertions - Add case to make sure display none is not on the option or optgroup itself * Fix failing assertion - where el was undefined when looking for visibiliyt * remove commented out code involving opacity 😬
This is still incorrectly failing in Cypress 4.9.0. |
After investigating this issue for quite a while, I recommend that we either de-prioritize it or close as won't fix. This issue has been open for around a year and a half now, and has no upvotes (compared to other more-requested fixes, which all have at least a couple). In addition, the fix is quite difficult technically. For starters, there's no way to easily get the dimensions of the clipping. The process would have to entail converting the clip-path to an svg, for which there is currently no standard library, so we would have to parse the value ourselves and convert that into a svg element. Next, we would have to see if that svg actually overlaps the underlying content, which we could do through A different potential solution would be assigning an on click handler, which would only be executed when the underlying element was actually clicked on. However, there is no guarantee of what part of the element would be exposed. For efficiency, we could test the center, then each of the corners, and then just each pixel linearly, but there is still the case that we might have to click on every single possible pixel. Plus, all those clicks could change the state of the underlying application. With that said, I can't see a solution that is efficient, viable, and flake free and this issue should be de-prioritized. (Selenium does visibility checking in a similar way to us, and does not handle |
using Is there any way to use a class like this in conjunction with Cypress visibility? |
@vacas5 You could potentially assert on the |
As the most common use of these properties is to hide the whole element without removing it from the DOM for accessibility purposes, maybe support only two special cases:
And simply document that for all other cases, the clip and clip-path properties will be ignored. |
Current behavior:
Elements hidden using the CSS
clip
/clip-path
properties pass visibility check.Desired behavior:
Visibility checks should fail as the element isn't visible.
How to reproduce:
Hide any element using CSS
clip
/clip-path
properties and define a test to check if it's visible. Test passes.Test code:
Additional Info (images, stack traces, etc)
While clip is deprecated clip-path is not. Unfortunately however clip is still used and supported so for the time being at least I think it should make visibility checks fail.
┆Issue is synchronized with this Jira Bug by Unito
The text was updated successfully, but these errors were encountered: