Cypress is unable to simulate the hover state on HTML element using the trigger('mouseover') workaround
See original GitHub issue- Operating System: Windows
- Cypress Version: “cypress”: “2.1.0”
- Browser Version: Electron 59
Bug
Current behavior:
When trying to simulate hover using the trigger(‘mouseover’) workaround mentioned in this link: https://docs.cypress.io/api/commands/hover.html# cypress does not simulate the hover action on the html element
Desired behavior:
Cypress should be able to simulate hover action on the element
How to reproduce:
Use the test code below to reproduce the issue.
Test code:
describe('Testing simulate hover state', () => {
it('Simulates the hover action ', () => {
cy.visit('https://www.w3schools.com/howto/howto_css_zoom_hover.asp');
cy.get('div.zoom').trigger('mouseover');
});
});
Additional Info (images, stack traces, etc)
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
How to test 'HOVER' using Cypress(.trigger('mouseover ...
The best way (imo) to identify which one works is, looking at the AUT's source code and use the same.
Read more >Simulating hovers in Cypress - Reflect.run
Despite having no native support for hovers, there are several workarounds that allow you to trigger hover states within your Cypress tests.
Read more >hover - Cypress Documentation
Sometimes an element has specific logic on hover and you do need to "hover" in Cypress. Maybe the element doesn't even display to...
Read more >Hover in Cypress - Filip Hric
Short guide on how to hover over elements in Cypress. As there are multiple ways hover actions work, there are multiple ways of...
Read more >cypress-io/cypress - Gitter
It's displayed/hidden entirely using css (there are no javascript or css classes). When a real user moves the mouse over the button, it...
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 FreeTop 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
Top GitHub Comments
Where is “here”??
What @Konstruktour is getting at is that Cypress does not trigger the CSS pseudo selectors in any current implementation of its hover workarounds.
If you have event listeners, in JavaScript, on mouse events - that will work, but something like the css zoom effect in the example will not work.
The full hover implementation (including reflecting css hover effects) is more fully outlined here and planned in the future. Currently css hover behavior does not work. Closing as duplicate.