playwright-fluent
Version:
Fluent API around playwright
53 lines (52 loc) • 1.86 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"));
describe('Playwright Fluent - invoke method on selector', () => {
let p;
beforeEach(() => {
p = new SUT.PlaywrightFluent();
});
afterEach(async () => {
await p.close();
});
test('should invoke click method on selector - chromium', async () => {
// Given
const url = `file:${path.join(__dirname, 'invoke-method.test.html')}`;
const selector = '#dynamically-added-input';
// When
await p
.withBrowser('chromium')
.withOptions({ headless: false })
.withCursor()
.navigateTo(url)
.expectThat(selector)
.isEnabled()
.invokeMethod('click', selector);
// Then
const isChecked = await p.isChecked(selector);
expect(isChecked).toBe(true);
// And
await p.expectThatSelector(selector).isChecked();
});
test('should invoke click method on selector object - chromium', async () => {
// Given
const url = `file:${path.join(__dirname, 'invoke-method.test.html')}`;
const selector = p.selector('input').withValue('dynamically added');
// When
await p
.withBrowser('chromium')
.withOptions({ headless: false })
.withCursor()
.navigateTo(url)
.expectThat(selector)
.isEnabled()
.invokeMethod('click', selector);
// Then
const isChecked = await selector.isChecked();
expect(isChecked).toBe(true);
// And
await p.expectThatSelector(selector).isChecked();
});
});
;