Skip to content

Scroll element into view when using .should('be.visible') #2892

Closed
@suchipi

Description

@suchipi

If you have a scrollable list of items, and want to verify that one of the items is in the list, the following isn't sufficient in all cases because it doesn't cause Cypress to scroll the element into view:

cy.contains('Hi').should('be.visible');

However, you can work around this by triggering an event on the element, which activates the scroll algorithm documented here:

cy.contains('Hi').trigger('dummy-event').should('be.visible');

Would the Cypress team be interested in a PR making a change such that this scroll algorithm is called when .should is called with 'be.visible'?

Current behavior:

Automatic scrolling does not occur when using .should('be.visible').

Desired behavior:

Automatic scrolling occurs when using .should('be.visible').

Versions

Cypress 3.1.1, macOS 10.13.6, Chrome 70

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions