Files
cypress/docs/source/api/commands/hover.md
T
Brian Mann 91bb010fd6 docs: fixes #231, cleanup all the API docs + notes
- go into more detail on trigger vs action commands
- explain actionability further
- better format notes + examples
- consistent no arg / arg examples
- es6 all the functions
- remove duplicated intractability content
- remove simulated events garbage
- go into more detail on pseudo action commands
- much better cy.contains usage
2017-06-30 18:33:52 -04:00

1.5 KiB

title, comments
title comments
hover false

{% note danger %} Cypress does not have a cy.hover() command. See {% issue 10 'Issue #10' %}. {% endnote %}

If cy.hover() is used, an error will display and redirect you to this page.

Workaround

Sometimes an element has specific logic on hover and you do need to "hover" in Cypress. Maybe the element doesn't even display to be clickable until you hover over another element.

Oftentimes you can use {% url .invoke() invoke %} or {% url cy.wrap() wrap %} to show the element before you perform the action.

Invoke

Example of showing an element in order to perform action

cy.get('.content').invoke('show').click()

{% note info %} {% url 'Check out our example recipe on testing hover and working with hidden elements' testing-the-dom %} {% endnote %}

You can also force the action to be performed on the element regardless of whether the element is visible or not.

Force click

Example of clicking on a hidden element

cy.get('.content').click({ force: true })

Example of checking a hidden element

cy.get('.checkbox').check({ force: true })

See also

  • {% url .invoke() invoke %}
  • {% url cy.wrap() wrap %}
  • {% url 'Recipe: Dealing with Hover and Hidden Elements' testing-the-dom %}