oWhen i scroll a page, the main menu header is visible.
cy.get('.myclass').scrollIntoView().within(() => { cy.get('.scroll').scrollTo('bottom') cy.get('.header-nav').should('not.exist') cy.get('.scroll').scrollTo('top') cy.get('.header-nav', {withinSubject: null}) })
Instead of , {withinSubject: null}) i want to use should('exist') but the test is failing when i use exist but pass when i use , {withinSubject: null})..Even with should be visible its failing.
First the header is showing like this in cypress:
- Its overlapping on the top
This is my html for the header:

What am i doing wrong or why is {withinSubject: null}) working and not others. When the site opens the header is present so when i use exist it works but once i check on the scroll the header does not work with exist. Also when i am scrolling down the header should not be visible but it is still visible even though when i do the same thing manually it works. Only having this behavior in cypress. Thank you