question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

cy.get({element}) causes page content to shift upward under a sticky header.

See original GitHub issue

Current behavior:

cy.get({element}) causes page to shift upward under sticky header.

On our entire site we’ve added an absolute positioned sticky header and now every cy.get(element) is causing the entire content of the page to shift upward under the header. This is preventing the clicking of dropdowns and menu items or even grid records. Everything we run the cy.get() on jumps to the top of the iframe. This shift cannot be reproduced locally outside of cypress. Using a click({force:true}) does not solve the issue as the element must be visible to work.

image

Desired behavior:

image

A cy.get() should not shift the page in any way whatsoever.

Steps to reproduce: (app code and test code)

We have a toolbar at the top of the entire site.

.top-nav {
    background-color: $top-nav-background-color;
    color: $top-nav-icons;
    height: $top-nav-bar-height;
    line-height: calc(#{$top-nav-bar-height} - 2px);
    width: 100%;
    z-index: 5;
    top: 0;
    left: 0;
    position: absolute;
    box-shadow: 0px 0px 15px rgba(0, 0, 0, 0.1);
}

At the initial cy.get to click the View button and select view filters, the page shifts and the button becomes obstructed. Even when using { force: true } the dropdown filter menu will not appear.

Versions

Cypress 3.4.1 Chrome 78 Angular 8 site

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
xtrinchcommented, Apr 2, 2020

@jennifer-shehane In my case it actually shifts a dropdown inside a modal upward, causing the modal to close upon clicking on the dropdown.

Although if I put a pause in the test, the dropdown is in its correct place, but cypress somehow clicks where the time travel shows the dropdown to be, causing the modal to close.

I can also visually see it shift up during the tests, not just in the snapshots.

Putting force: true inside the click fixes my issue completely though.

0reactions
xtrinchcommented, Nov 15, 2022
Read more comments on GitHub >

github_iconTop Results From Across the Web

Interacting with Elements - Cypress Documentation
Ensure the element is not animating. Ensure the element is not covered. Scroll the page if still covered by an element with fixed...
Read more >
Cypress scrolling behaviour on `get` and relative positionning
Show activity on this post. When calling Cypress cy. get method, the page is scrolled so that the selected element is at the...
Read more >
cypress-io/cypress - Gitter
The element is visible on the page, but when using .type(...) it scrolls to the element, not taking into account the sticky nav,...
Read more >
Content Security Policy (CSP) - HTTP - MDN Web Docs
Chrome Edge Content‑Security‑Policy Full support. Chrome25. more. Toggle history Full sup... base‑uri Full support. Chrome40. Toggle history Full sup... block‑all‑mixed‑content. Deprecated Full support. ChromeYes. Toggle history...
Read more >
Svelte Shy Header: Peekaboo Sticky Header with CSS
Svelte shy header: how to add a vanishing, sticky peekaboo header that reappears when the user scrolls up using Svelte and CSS to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found