-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
[Feature] Mouse wheel or page.scroll #1115
Comments
Could you share more about scenario? Are there |
One use case is to test an infinite scroll component. Keep scrolling down in the x or y axis until the scrollLeft / scrollTop reaches a value. Right now I am doing this with evaluate which works, I was just hoping to have a playwright API I could use. |
I think this evaluate script is reasonable for now, because it matches the exact semantics you care about. If we were to introduce scrolling, it would be more like user interaction as you proposed (either a mouse wheel scroll or touchscreen/touchpad scroll gesture), and it's unclear how to "wait for completion" in this case. For infinite lists, perhaps |
Sounds good, I have workarounds but will leave this issue open for a potential future API. Right now I am using The way the auto-waiting could work is that it would resolve after the corresponding "scroll" was completed. If the scroll could not be completed (the page could not scroll that amount), it would throw an error. |
+1 for API-native mouseWheel or scroll to bottom |
I'd like this for xterm.js, I'm currently figuring out how to update our playwright private API usage that ensures wheel events get correctly serialized depending on the terminal mouse mode: |
Perhaps a "Scroll element until some selector hits or timeout" behavior? That would likely be a solid solution for infinite lists. Although my current solution seems to work rather fine with a bit of tweaking perhaps to get to a certain item within an infinite list. Below is just getting to the bottom. await page.waitForSelector('.row-item');
const scrollToBottomOfInfiniteList = async prev => {
const items = await page.$$('.row-item');
const lastItemRendered = items[items.length - 1];
const control = prev ?? await lastItemRendered.getAttribute('data-index');
await lastItemRendered.scrollIntoViewIfNeeded();
await page.waitForTimeout(100); // going straight to the next eval wasn't catching the newly rendered row items
const experiment = await page.$$eval(
'.row-item',
els => els[els.length - 1].dataset.index // row-items have data-index attributes revealing their true index
);
if (control === experiment) return;
await scrollToBottomOfInfiniteList(experiment);
};
await scrollToBottomOfInfiniteList();
await page.waitForTimeout(15000);
}; |
I have another case when mouse wheel is required - zooming. I have a webpage where zooming in/out works only with Ctrl+Mouse Wheel. So there is not way to do it with scrollIntoViewIfNeeded :) |
I also need to test mouse wheel. I have I would love to see support for simulating This is my component, which I want to test the |
Another workaround of |
+1 for this feature, especially for tables, when scrolling horizontally. |
Without this feature how are we supposed to load dynamic content from websites that load content by scrolling down |
+1 We also need this to navigate inside a carousel |
+1 We need it to test zoom in/out of a map component. |
Closing since landed in #8690 |
It would be nice to have a cross browser way to test scrolling.
Ex. via CDP
For an auto-wait API, you could keep trying to scroll to a point and timeout if it cannot reach it.
The text was updated successfully, but these errors were encountered: