Open jan-surincik opened 1 month ago
@jan-surincik It would be helpful if you could provide an example HTML file that shows the styles / elements being used to demonstrate the problem.
Usually when I run into this problem its because I'm trying to scroll the wrong element. Like I think the body has the scroll, but it's really some inner element, but I couldn't tell if this is the case without an example.
Current behavior
I am trying to test the scroll lock service in our application, test scenario: The user opens the nav-bar, after that, the body is locked and the user is not able to scroll through the body
so this service adds style to the body
overflow: hidden
andheight: 100vh
, so the body is not scrollable after clicking on the nav itemBasic test:
I also tried invoking CSS to the body element to make sure the body is scrollable
I have to note, that changing the viewport also doesn't help and also I tried to solve this with scrollToView(), but this method totally ignores
overflow: 'hidden'
oroverflow: 'clip'
and it always scrolls no matter if the body is locked. Our scroll-lock works correctly and it was manually tested.Errors:
If someone has some workaround to this I will be happy if you share it, hopefully, I described my problem understandably.
Desired behavior
If the element has
overflow: 'auto'
or is scrollable Cypress should be able to use scrollTo in this element.example:
cy.get('body').scrollTo('bottom')
- should work on the scrollable elementand if the element is not scrollable scrollIntoView() should fail the test
example:
cy.get('body').scrollIntoView({offset: {top: 500, left: 0}});
- should not work on non-scrollable elementTest code to reproduce
scrollTo():
scrollIntoView()
Cypress Version
v12.17.4
Node version
v18.20.1
Operating System
macOs 14.5