Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduced new error message for position:fixed and needs scroll. #5594

Merged
merged 2 commits into from
Nov 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/driver/src/dom/visibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -448,11 +448,15 @@ const getReasonIsHidden = function ($el) {
// show the long element here
const covered = $elements.stringify(elAtCenterPoint($el))

return `\
if (covered) {
return `\
This element '${node}' is not visible because it has CSS property: 'position: fixed' and its being covered by another element:

${covered}\
`
}

return `This element '${node}' is not visible because its ancestor has 'position: fixed' CSS property and it is overflowed by other elements. How about scrolling to the element with cy.scrollIntoView()?`
}
} else {
if (elIsOutOfBoundsOfAncestorsOverflow($el)) {
Expand Down
11 changes: 11 additions & 0 deletions packages/driver/test/cypress/integration/dom/visibility_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,17 @@ This element '<div#coveredUpPosFixed>' is not visible because it has CSS propert
`)
})

it('needs scroll', function () {
const el = cy.$$('body').append(`
<div style="position: fixed; top: 0; right: 0; bottom: 0; left: 0; overflow-x: hidden; overflow-y: auto;">
<div style="height: 800px">Big Element</div>
<button id="needsScroll">MyButton</button>
</div>
`)

this.reasonIs(el.find('#needsScroll'), `This element \'<button#needsScroll>\' is not visible because its ancestor has 'position: fixed' CSS property and it is overflowed by other elements. How about scrolling to the element with cy.scrollIntoView()?`)
})

it('cannot determine why element is not visible', function () {
this.reasonIs(this.$btnOpacity, 'Cypress could not determine why this element \'<button>\' is not visible.')
})
Expand Down