Use Puppeteer's ElementHandle.boundingBox() API in the integration tests

The custom solution for obtaining the bounding box of a given element
that we have now was necessary during the original introduction of the
integration tests because at the time the `ElementHandle.boundingBox()`
API in Puppeteer didn't work correctly in Chrome.

However, `getRect`, where this is used, is a hot utility function
because most tests call it multiple times, either directly or indirectly
via other utility functions, and it turns out that the approach we use
is slower than the native `ElementHandle.boundingBox()` API.

Fortunately, most likely after a combination of Chrome/Puppeteer updates
and the conversion to the formalized WebDriver BiDi protocol the custom
solution is no longer necessary because all tests pass without it too,
so this commit converts `getRect` to use `ElementHandle.boundingBox()`
instead to speed up the tests.
This commit is contained in:
Tim van der Meij 2026-05-14 13:46:25 +02:00
parent 65b8aec420
commit 62b88aa56e
No known key found for this signature in database
GPG Key ID: 8C3FD2925A5F2762

View File

@ -268,13 +268,8 @@ function getSelector(id) {
}
async function getRect(page, selector) {
// In Chrome something is wrong when serializing a `DomRect`,
// so we extract the values and return them ourselves.
await page.waitForSelector(selector, { visible: true });
return page.$eval(selector, el => {
const { x, y, width, height } = el.getBoundingClientRect();
return { x, y, width, height };
});
return (await page.$(selector)).boundingBox();
}
function getQuerySelector(id) {