I am testing my application where I have very long side menu and I have a code like that:
cy.get('tab').click({force: true})
The automatic scroll happens between get and click and then selected tab is not visible since the top menu has possition fixed. I found many solutions but none of them worked. So far I tried .click({force: true}) and .click(scrollBehaviour: false}) also .scrollIntoView() between get and click.
Is there any other way to solve this issue?
You can set the scrollBehavior globally or per test(-suite).
I'm disabling it on a per tests basis like so:
it('check something w/ autoscroll disabled', { scrollBehavior: false }, () => {
cy.get('.tab').click();
// do something else ...
});
Docs: https://docs.cypress.io/guides/references/configuration#Actionability
Did you try using scrollBehaviour: 'top' ?
You can find more details regarding the ScrollBehaviour here:
https://docs.cypress.io/guides/core-concepts/interacting-with-elements#Scrolling https://docs.cypress.io/guides/references/configuration#Actionability https://docs.cypress.io/api/commands/click#Arguments
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With