UNPKG

playwright-fluent

Version:
90 lines (89 loc) 3.27 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const path = tslib_1.__importStar(require("path")); const SUT = tslib_1.__importStar(require("../../playwright-fluent")); const utils_1 = require("../../../utils"); describe('Playwright Fluent - expectThat isChecked', () => { let p; beforeEach(() => { p = new SUT.PlaywrightFluent(); }); afterEach(async () => { await p.close(); }); test('should give back an error when selector does not exists', async () => { // Given const url = `file:${path.join(__dirname, 'expect-is-checked.test.html')}`; const selector = 'foobar'; // When let result = undefined; try { await p .withBrowser('chromium') .withOptions({ headless: false }) .withCursor() .navigateTo(url) .expectThatSelector(selector) .isChecked({ timeoutInMilliseconds: 2000 }); } catch (error) { result = error; } // Then expect(result && result.message).toContain("Selector 'foobar' was not found in DOM."); }); test('should give back an error when selector object does not exists', async () => { // Given const url = `file:${path.join(__dirname, 'expect-is-checked.test.html')}`; const selector = p.selector('foobar'); // When let result = undefined; try { await p .withBrowser('chromium') .withOptions({ headless: false }) .withCursor() .navigateTo(url) .expectThatSelector(selector) .isChecked({ timeoutInMilliseconds: 2000 }); } catch (error) { result = error; } // Then expect(result && result.message).toContain("Selector 'selector(foobar)' was not found in DOM."); }); test('should wait until selector exists and is checked - chromium', async () => { // Given const url = `file:${path.join(__dirname, 'expect-is-checked.test.html')}`; const selector = '#dynamically-added-checkbox'; // When await p .withBrowser('chromium') .withOptions({ headless: false }) .withCursor() .navigateTo(url) .expectThatSelector(selector) .isChecked(); // Then const isChecked = await p.isChecked(selector, utils_1.noWaitNoThrowOptions); expect(isChecked).toBe(true); }); test('should wait until selector object exists and is checked - chromium', async () => { // Given const url = `file:${path.join(__dirname, 'expect-is-checked.test.html')}`; const selector = p.selector('input').withValue('dynamically added'); // When await p .withBrowser('chromium') .withOptions({ headless: false }) .withCursor() .navigateTo(url) .expectThatSelector(selector) .isChecked(); // Then const isChecked = await selector.isChecked(); expect(isChecked).toBe(true); }); });