Conversation
This gets us closer to the end-goal, but it's still far off
Member
|
Btw I came across this issue puppeteer/puppeteer#4690, that says there might be some issues with headless mode with this approach, would be good to ensure it works fine with headless (haven't checked, maybe the tests are already using headless). (its quite old, so probably not relevant, but still...) |
Member
Author
|
I used this script to test these changes (since jest was waay too slow for my likings), and it worked, tho I needed to increate the timeout between scrolls to make stopScrollCallback work as before const { launchPuppeteer, utils } = require('.');
(async () => {
const browser = await launchPuppeteer({ launchOptions: { headless: true } });
const page = await browser.newPage();
let count = 0;
const content = Array(1000).fill(null).map(() => {
return `<div style="border: 1px solid black">Div number: ${count++}</div>`;
});
const contentHTML = `<html><body>${content}</body></html>`;
await page.setContent(contentHTML);
function isAtBottom() {
return (window.innerHeight + window.scrollY) >= document.body.offsetHeight;
}
const before = await page.evaluate(isAtBottom);
console.log(before);
await utils.puppeteer.infiniteScroll(page, { waitForSecs: Infinity, stopScrollCallback: () => true });
// await utils.puppeteer.infiniteScroll(page, { waitForSecs: 0 });
const after = await page.evaluate(isAtBottom);
console.log(after);
console.log(await page.evaluate(() => ({
innerHeight: window.innerHeight,
scrollY: window.scrollY,
innerHeightPlusYOffset: window.innerHeight + window.scrollY,
offsetHeight: document.body.offsetHeight,
})));
await page.close();
await browser.close();
})(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This should close #1010 (but I don't know if this is the API you referred to in your issue, and it's the only other relevant example I found for scrolling). There's still a bug I need to find out why it breaks (for some reason the test case for
waitForSecs: Infinity, scrollCancelCallbackthrows..)