Hover over button using Cypress

Viewed 1698

I'm trying to hover over a button in Cypress and for that I've tried to use trigger('mouseover') but it is not working for me. Any suggestions?

  it('hovering over button', () => {
cy.visit("http://www.qaclickacademy.com/practice.php");
cy.get('#mousehover').trigger('mouseover'); })
2 Answers

I've finally found a workaround for this. With the use of Invoke() method in my code I was able to hover over a button.

  it('hovering over button', () => {
  cy.visit("http://www.qaclickacademy.com/practice.php");
  cy.get('.mouse-hover-content').should('be.hidden').invoke('show');
  })

The answer above helped me to find the solution for me:

cy.get('.mouse-hover-content')
  .should('be.hidden')
  .invoke('css', 'visibility', 'visible')
Related