playwright-fluent
Version:
Fluent API around playwright
43 lines (42 loc) • 2.02 kB
JavaScript
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('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 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, '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.defaultClickOptions,
};
// When
await SUT.clickOnSelector(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);
});
});
;