I am trying to intercept XHR resources as I lazyload content with Playwright.
I am using this, which works well the first time.
const content = await page.waitForResponse((response) =>
response.url().includes('somedata.json')
)
const { data } = await content.json()
The problem is that when I lazyload the content by scrolling, it always gets the same content and does not load the new somedata.json that gets generated as I keep scrolling.
const results = await page.evaluate(async (data) => {
let arr = []
for (let i = 0; i < document.body.scrollHeight; i += 100) {
arr.push(...Object.values(data))
window.scrollTo(0, i)
}
return arr
}, data)
Is there a way to trigger a new interception inside page.evaluate?