UNPKG

playwright-fluent

Version:
45 lines (44 loc) 2.2 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 handle_actions_1 = require("../../../handle-actions"); const has_handle_focus_1 = require("../../../handle-actions/has-handle-focus"); describe('double click on selector', () => { let browser = undefined; // eslint-disable-next-line @typescript-eslint/no-empty-function beforeEach(() => { }); afterEach(async () => { if (browser) { await browser.close(); } }); test('should wait for the selector to be enabled before double clicking - 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, 'double-click-on-selector.test.html')}`; await page.goto(url); const selector = '#dynamically-added-input'; let handle = await page.$(selector); const isSelectorVisibleBeforeClick = await (0, handle_actions_1.isHandleVisible)(handle, handle_actions_1.defaultVerboseOptions); const options = { ...handle_actions_1.defaultDoubleClickOptions, }; // When await SUT.doubleClickOnSelector(selector, page, options); handle = await page.$(selector); const isSelectorVisibleAfterClick = await (0, handle_actions_1.isHandleVisible)(handle, handle_actions_1.defaultVerboseOptions); // Then expect(isSelectorVisibleBeforeClick).toBe(false); expect(isSelectorVisibleAfterClick).toBe(true); expect(await (0, has_handle_focus_1.hasHandleFocus)(handle)).toBe(true); const selectedText = await page.evaluate(() => (document.getSelection() || '').toString()); expect(selectedText).toBe('dynamically'); }); });