-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Open
Description
Minimal, reproducible example
import puppeteer from 'puppeteer'
const browser = await puppeteer.launch({headless: false})
const page = await browser.newPage()
await page.setContent(
'<div name="scrollContainer" style="width: 150px;height: 200px;background-color: blanchedalmond;position: relative;overflow: auto;"><div style="margin: 30px; width: 600px;height: 75px;background-color: blueviolet;position: relative" id="element1"></div><div style="margin: 30px; width: 600px;height: 75px;background-color: blueviolet;position: relative" id="element2"></div></div>'
)
const handle = await page.waitForSelector('#element2')
await handle.click()
Background
No response
Expectation
the center of the element is outside the scroll container
Reality
By default, new versions of puppeteer use client.send('DOM.scrollIntoViewIfNeeded', {objectId: this.id})
to autoscroll to an element, but this differs from the previously used method element.scrollIntoView({block: 'center',inline: 'center',behavior: 'instant'})
- the method does not scroll to the center of the element and when trying to click on the element - the click occurs outside the scroll container
Puppeteer configuration file (if used)
Puppeteer version
24.11.2
Node version
v20.18.3
Package manager
npm
Package manager version
10.8.2
Operating system
Linux