playwright-fluent
Version:
Fluent API around playwright
28 lines (27 loc) • 1.18 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.switchFromHandleToIframe = exports.defaultSwitchToIframeOptions = void 0;
const hover_on_handle_1 = require("../hover-on-handle");
const dom_actions_1 = require("../../dom-actions");
exports.defaultSwitchToIframeOptions = {
...hover_on_handle_1.defaultHoverOptions,
injectCursor: true,
};
async function switchFromHandleToIframe(selector, name, pageOrFrame, options) {
if (!pageOrFrame) {
throw new Error(`Cannot switch to iframe from '${name}' because no browser has been launched`);
}
if (!selector) {
throw new Error(`Cannot switch to iframe from '${name}' because selector was not found in DOM`);
}
await (0, hover_on_handle_1.hoverOnHandle)(selector, name, pageOrFrame, options);
const frame = await selector.contentFrame();
if (!frame) {
throw new Error(`Cannot switch to iframe from '${name}' because this selector does not seem to be an iframe.`);
}
if (options.injectCursor) {
await (0, dom_actions_1.injectCursor)(frame);
}
return frame;
}
exports.switchFromHandleToIframe = switchFromHandleToIframe;
;