playwright-fluent
Version:
Fluent API around playwright
90 lines (89 loc) • 3.29 kB
JavaScript
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 isEnabled', () => {
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-enabled.test.html')}`;
const selector = 'foobar';
// When
let result = undefined;
try {
await p
.withBrowser('chromium')
.withOptions({ headless: false })
.withCursor()
.navigateTo(url)
.expectThatSelector(selector)
.isEnabled({ 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-enabled.test.html')}`;
const selector = p.selector('foobar');
// When
let result = undefined;
try {
await p
.withBrowser('chromium')
.withOptions({ headless: false })
.withCursor()
.navigateTo(url)
.expectThatSelector(selector)
.isEnabled({ 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 enabled - chromium', async () => {
// Given
const url = `file:${path.join(__dirname, 'expect-is-enabled.test.html')}`;
const selector = '#dynamically-added-input';
// When
await p
.withBrowser('chromium')
.withOptions({ headless: false })
.withCursor()
.navigateTo(url)
.expectThatSelector(selector)
.isEnabled();
// Then
const isEnabled = await p.isEnabled(selector, utils_1.noWaitNoThrowOptions);
expect(isEnabled).toBe(true);
});
test('should wait until selector object exists and is enabled - chromium', async () => {
// Given
const url = `file:${path.join(__dirname, 'expect-is-enabled.test.html')}`;
const selector = p.selector('input').withValue('dynamically added');
// When
await p
.withBrowser('chromium')
.withOptions({ headless: false })
.withCursor()
.navigateTo(url)
.expectThatSelector(selector)
.isEnabled();
// Then
const isEnabled = await p.isEnabled(selector, utils_1.noWaitNoThrowOptions);
expect(isEnabled).toBe(true);
});
});
;