asoni
asoni

Reputation: 53

Hover over button using Cypress

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'); })

Upvotes: 2

Views: 3084

Answers (2)

Artem S
Artem S

Reputation: 66

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

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

Upvotes: 0

asoni
asoni

Reputation: 53

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');
  })

Upvotes: 1

Related Questions