-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Enable users to change the scrolling strategy #871
Comments
Just expressing another usecase where disabling scrolling would be useful. I am currently writing tests for mobile viewport, which in real life is never supposed to be able to scroll itself, and because of how cypress scrolls elements into view a lot of the times they end up being hidden and are not asserted correctly by On the other hand some other elements which are normally positioned offscreen for animations become visible, and are also incorrectly asserted using visibility checks. |
I think my problem touches the same area: |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This issue is still in the 'proposal' stage, some initial proof of concept work as well as background architecture work has been done, but the issue itself has no work done on it as of today, we do not have an estimate on when this will be delivered. |
@jennifer-shehane wondering what it will take to move this out of proposal? The web is built on scrolling viewports. Yet cypress resets scroll position every time you Using |
I'd like to also throw in my support for this fix. I'm seeing the unwanted scroll occur on the |
@JohnMCrooks Today I have made a new test using the 4.4.1 version and the workaround is working well for me |
I had an issue with the workaround @bakjos posted in a specific scenario, though it worked with the majority of cases. When an element was not virtualized but was slightly off screen - it would get into an infinite loop, scrolling would trigger the let $lastEl: JQuery<HTMLElement>;
let hasScrolled = false;
Cypress.on('scrolled', ($el) => {
if ($el.is($lastEl)) {
if (hasScrolled) {
return;
}
hasScrolled = true;
} else {
$lastEl = $el;
hasScrolled = false;
}
$el.get(0).scrollIntoView({
block: 'center',
inline: 'center',
});
}); |
This comment has been minimized.
This comment has been minimized.
I'm adding e2e tests for user profiles. These tests verify that: * Users can update their phone number * Users can't enter an invalid phone number I ran into a documented issue with Cypress where it isn't properly scrolling an element into view. This issue is being tracked at: cypress-io/cypress#871. I forced a few actions to work around this, but there are some additional workaround options suggested on the issue page.
I'm adding e2e tests for user profiles. These tests verify that: * Users can update their phone number * Users can't enter an invalid phone number I ran into a documented issue with Cypress where it isn't properly scrolling an element into view. This issue is being tracked at: cypress-io/cypress#871. I forced a few actions to work around this, but there are some additional workaround options suggested on the issue page.
I'm adding e2e tests for user profiles. These tests verify that: * Users can update their phone number * Users can't enter an invalid phone number I ran into a documented issue with Cypress where it isn't properly scrolling an element into view. This issue is being tracked at: cypress-io/cypress#871. I forced a few actions to work around this, but there are some additional workaround options suggested on the issue page.
Sorry, no updates here. We are prioritizing other work over this at the moment. |
I did review the comments here and am finding a lot of people saying they need to control the scroll behavior because they have to pass We're only aware of a couple of issues where this happens in the current 4.12.1 version now - many of these issues have been resolved since this was opened. Scrolling causes visibility error
Please open an issueIf you're having a situation where Cypress is incorrectly determining the visibility of an element because of scrolling, and it doesn't fall under the issues above, then we are not aware of it. We suggest opening a new issue with a fully reproducible example so that we can fix the core visibility algorithm and you won't need the scrolling workaround in the first place. This will likely get your issue fixed quicker than waiting for this scrolling strategy feature. |
Hey @jennifer-shehane , I am also facing issues with ScrollTo and ScrollIntoView methods. I wanted to scroll down the Application Under test window while running tests,to test lazy loaded ads. Scroll works fine when I am viewing the tests. But once I Minimize the test window, scroll do not work, also I do not get any kind of error. cy.scrollTo('bottom')`
cy.window.scrollTo('bottom')`
cy.get('.container-main > .header > .title').scrollIntoView({force:true}).should('be.visible') Try this code : it('Scrolling',function() {
cy.visit("https://css-tricks.com/snippets/javascript/lazy-loading-images/")
cy.scrollTo('0%','25%')
cy.wait(5000)
cy.get('.fem-learning-partner').should('be.visible').and('contain.text','Our Learning Partner')
}) All this works, when I just open Cypress test window and looking on behavior of my tests doing nothing else. :( Why scrolling fails when I am not viewing/minimizing the cypress test window ? Is this an open issue with Cypress ? I am not able to complete many tests cases of my project due to this issue,my application is on vue-js. Can you please suggest something. It will be a big help. |
@Sakshi3110 There are some issues covering this here: #5023 But they may not all be caused by the same situation. |
@jennifer-shehane Thanks! I checked #5023 , May be I also need something in my code, which keeps Test Runner/Application under test browser in ACTIVE mode. So, that focus remains active even after minimizing windows. |
How long do we wait for solution? |
Please provide workaround if you are not going to fix it. |
Currently, this is just a proposal without any work planned in the nearest future. |
Any suggestion how to test components which close itself when page is scrolled? E.g. fluent-ui contextual menu components here https://developer.microsoft.com/en-us/fluentui#/controls/web/contextualmenu#IContextualMenuProps - try to click on button and then scroll the page ... I am working on Cypress tests where I am unable to click on menu item because once menu is opened and I try to click on menu item, page is scrolled, menu closes and Cypress fails because menu item element does not exists in the DOM. Edit:
|
The code for this is done in cypress-io/cypress#8837, but has yet to be released. |
Released in This comment thread has been locked. If you are still experiencing this issue after upgrading to |
In Cypress 6.1.0, there’s a new If you're experiencing a bug similar to this in Cypress, please open a new issue with a fully reproducible example that we can run. There may be a specific edge case with the issue that we need more detail to fix. |
Users have expressed a desire to modify how Cypress internally scrolls elements.
Related to:
Currently we pin elements to the topmost coordinate after scrolling.
Users should be able to change this strategy to be one of:
future
- [ ] By default, scroll element into centerThe text was updated successfully, but these errors were encountered: