fix: add multiple scroll approach

This commit is contained in:
Rohit
2025-08-28 15:29:14 +05:30
parent 4b68efb05b
commit 49b0c484b9

View File

@@ -734,10 +734,22 @@ export default class Interpreter extends EventEmitter {
return allResults; return allResults;
} }
await page.evaluate(() => window.scrollTo(0, document.body.scrollHeight)); await page.evaluate(() => {
const scrollHeight = Math.max(
document.body.scrollHeight,
document.documentElement.scrollHeight
);
window.scrollTo(0, scrollHeight);
});
await page.waitForTimeout(2000); await page.waitForTimeout(2000);
const currentHeight = await page.evaluate(() => document.body.scrollHeight); const currentHeight = await page.evaluate(() => {
return Math.max(
document.body.scrollHeight,
document.documentElement.scrollHeight
);
});
const currentResultCount = allResults.length; const currentResultCount = allResults.length;
if (currentResultCount === previousResultCount) { if (currentResultCount === previousResultCount) {
@@ -1024,10 +1036,22 @@ export default class Interpreter extends EventEmitter {
// Wait for content to load and check scroll height // Wait for content to load and check scroll height
await page.waitForTimeout(2000); await page.waitForTimeout(2000);
await page.evaluate(() => window.scrollTo(0, document.body.scrollHeight)); await page.evaluate(() => {
const scrollHeight = Math.max(
document.body.scrollHeight,
document.documentElement.scrollHeight
);
window.scrollTo(0, scrollHeight);
});
await page.waitForTimeout(2000); await page.waitForTimeout(2000);
const currentHeight = await page.evaluate(() => document.body.scrollHeight); const currentHeight = await page.evaluate(() => {
return Math.max(
document.body.scrollHeight,
document.documentElement.scrollHeight
);
});
const heightChanged = currentHeight !== previousHeight; const heightChanged = currentHeight !== previousHeight;
previousHeight = currentHeight; previousHeight = currentHeight;