UNPKG

playwright-fluent

Version:
16 lines (15 loc) 532 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getFocusedHandle = void 0; async function getFocusedHandle(page) { if (!page) { throw new Error(`Cannot get focused handle because no browser has been launched`); } const focusedElement = await page.evaluateHandle(() => window.document.activeElement); if (focusedElement === null) { return null; } const handle = focusedElement.asElement(); return handle; } exports.getFocusedHandle = getFocusedHandle;