UNPKG

playwright-fluent

Version:
42 lines (41 loc) 1.86 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 press_key_1 = require("../../press-key"); const utils_1 = require("../../../../utils"); describe('hold down key', () => { let browser = undefined; // eslint-disable-next-line @typescript-eslint/no-empty-function beforeEach(() => { }); afterEach(async () => { if (browser) { await browser.close(); } }); test('should hold down key SHIFT - 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, 'hold-down-key.test.html')}`; await page.goto(url); await (0, utils_1.sleep)(1000); const selector = '#emptyInput'; await page.click(selector); const handle = await page.$(selector); // When await SUT.holdDownKey('Shift', page); await (0, press_key_1.pressKey)('KeyA', page, press_key_1.defaultKeyboardPressOptions); await (0, press_key_1.pressKey)('KeyB', page, press_key_1.defaultKeyboardPressOptions); await page.keyboard.up('Shift'); await (0, press_key_1.pressKey)('KeyA', page, press_key_1.defaultKeyboardPressOptions); // Then // eslint-disable-next-line @typescript-eslint/no-non-null-assertion expect(await handle.evaluate((node) => node.value)).toBe('ABa'); }); });