From c17eea7a3c8133a94d1179fbcb2ac19cba9d896b Mon Sep 17 00:00:00 2001 From: Pavel Feldman Date: Fri, 3 Mar 2023 09:13:25 -0800 Subject: [PATCH] chore: fix xpath-in-iframe (#21367) Fixes https://github.com/microsoft/playwright/issues/21364 --- .../playwright-core/src/server/injected/xpathSelectorEngine.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/playwright-core/src/server/injected/xpathSelectorEngine.ts b/packages/playwright-core/src/server/injected/xpathSelectorEngine.ts index f12dd4d3f4..7964ef4d46 100644 --- a/packages/playwright-core/src/server/injected/xpathSelectorEngine.ts +++ b/packages/playwright-core/src/server/injected/xpathSelectorEngine.ts @@ -21,7 +21,7 @@ export const XPathEngine: SelectorEngine = { if (selector.startsWith('/')) selector = '.' + selector; const result: Element[] = []; - const document = root instanceof Document ? root : root.ownerDocument; + const document = root.ownerDocument || root; if (!document) return result; const it = document.evaluate(selector, root, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE);