Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

chore(bidi): return null for elements without a bounding box (#40463)

Holger Benldb7e66676805
diff --git a/packages/playwright-core/src/server/bidi/bidiPage.ts b/packages/playwright-core/src/server/bidi/bidiPage.ts
index f3d19d9161..6637b0d46e 100644
--- a/packages/playwright-core/src/server/bidi/bidiPage.ts
+++ b/packages/playwright-core/src/server/bidi/bidiPage.ts
@@ -517,7 +517,7 @@ export class BidiPage implements PageDelegate {
async getBoundingBox(handle: dom.ElementHandle): Promise<types.Rect | null> {
const box = await handle.evaluate(element => {
- if (!(element instanceof Element))
+ if (!(element instanceof Element) || element.getClientRects().length === 0)
return null;
const rect = element.getBoundingClientRect();
return { x: rect.x, y: rect.y, width: rect.width, height: rect.height };
diff --git a/tests/bidi/expectations/moz-firefox-nightly-page.txt b/tests/bidi/expectations/moz-firefox-nightly-page.txt
index 8241a8369e..9b897f3562 100644
--- a/tests/bidi/expectations/moz-firefox-nightly-page.txt
+++ b/tests/bidi/expectations/moz-firefox-nightly-page.txt
@@ -1,4 +1,3 @@
-page/elementhandle-bounding-box.spec.ts › should return null for invisible elements [fail]
page/elementhandle-click.spec.ts › should double click the button [fail]
page/elementhandle-click.spec.ts › should work for TextNodes [fail]
page/elementhandle-content-frame.spec.ts › should work for cross-frame evaluations [fail]