UNPKG

playwright-fluent

Version:
61 lines (60 loc) 2.17 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const path_1 = tslib_1.__importDefault(require("path")); const playwright_fluent_1 = require("../../playwright-fluent"); describe('Playwright Fluent - typeTextInDialogAndSubmit()', () => { let p; beforeEach(() => { p = new playwright_fluent_1.PlaywrightFluent(); }); afterEach(async () => { await p.close(); }); test('should type text and submit dialog prompt - chromium', async () => { // Given const browser = 'chromium'; const url = `file:${path_1.default.join(__dirname, 'typetext-in-dialog-and-submit-prompt.test.html')}`; const answerSelector = '#answer'; // When await p .withBrowser(browser) .withOptions({ headless: true }) .WithDialogs() .navigateTo(url) .expectThat(answerSelector) .hasValue('waiting for your answer ...') .waitForDialog() .expectThatDialog() .isOfType('prompt') .expectThatDialog() .hasMessage('yo?') .expectThatDialog() .hasValue('yes') .typeTextInDialogAndSubmit('foobar') // Then .expectThat(answerSelector) .hasValue('foobar'); }); test('should assert that no dialog has been opened - chromium', async () => { // Given const browser = 'chromium'; const url = `file:${path_1.default.join(__dirname, 'typetext-in-dialog-and-submit-prompt.test.html')}`; // When let result = undefined; try { await p .withBrowser(browser) .withOptions({ headless: true }) //.WithDialogs() => be sure that no dialog opens .navigateTo(url) // Then .typeTextInDialogAndSubmit('foobar'); } catch (error) { result = error; } // Then expect(result && result.message).toContain('Cannot accept dialog because no dialog has been opened'); }); });