question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 6 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

9reactions
DavidGWheelercommented, Sep 5, 2019
  • “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.”

Where is “here”??

1reaction
jennifer-shehanecommented, May 2, 2018

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found