UNPKG

playwright-fluent

Version:
45 lines (44 loc) 2.18 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const path = tslib_1.__importStar(require("path")); const playwright_1 = require("playwright"); const SUT = tslib_1.__importStar(require("../index")); const dom_actions_1 = require("../../../dom-actions"); const inject_cursor_1 = require("../../../dom-actions/inject-cursor"); const index_1 = require("../index"); describe('clear-text', () => { let browser = undefined; // eslint-disable-next-line @typescript-eslint/no-empty-function beforeEach(() => { }); afterEach(async () => { if (browser) { await browser.close(); } }); test('should clear text that is inside an iframe - chromium', async () => { // Given browser = await playwright_1.chromium.launch({ headless: true }); const browserContext = await browser.newContext({ viewport: null }); const page = await browserContext.newPage(); await (0, dom_actions_1.showMousePosition)(page); const url = `file:${path.join(__dirname, 'clear-text.test.html')}`; await page.goto(url); const frameSelector = 'iframe'; const frameHandle = await page.$(frameSelector); const frame = await (frameHandle === null || frameHandle === void 0 ? void 0 : frameHandle.contentFrame()); await (0, inject_cursor_1.injectCursor)(frame); frameHandle === null || frameHandle === void 0 ? void 0 : frameHandle.hover(); const selector = '#input-inside-iframe'; // eslint-disable-next-line @typescript-eslint/no-non-null-assertion const handle = await frame.$(selector); await (handle === null || handle === void 0 ? void 0 : handle.hover()); await (handle === null || handle === void 0 ? void 0 : handle.click()); // When // eslint-disable-next-line @typescript-eslint/no-non-null-assertion await SUT.clearText(frame, index_1.defaultClearTextOptions); // Then // eslint-disable-next-line @typescript-eslint/no-non-null-assertion expect(await handle.evaluate((node) => node.value)).toBe(''); }); });