playwright-fluent
Version:
Fluent API around playwright
85 lines (84 loc) • 3.05 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 - switchToIframe', () => {
let p;
beforeEach(() => {
p = new SUT.PlaywrightFluent();
});
afterEach(async () => {
await p.close();
});
test('should switch to iframe - chromium', async () => {
// Given
const url = `file:${path.join(__dirname, 'switch-to-iframe.test.html')}`;
const selector = 'iframe';
const inputInIframe = '#input-inside-iframe';
// When
await p
.withBrowser('chromium')
.withOptions({ headless: false })
.withCursor()
.navigateTo(url)
.hover(selector)
.switchToIframe(selector)
.expectThat(inputInIframe)
.hasValue('I am in an iframe')
.click(inputInIframe)
.typeText('foobar')
.expectThat(inputInIframe)
.hasValue('foobar');
// Then
const value = await p.getValueOf(inputInIframe);
expect(value).toBe('foobar');
});
test('should switch to an iframe targeted by a fluent selector - chromium', async () => {
// Given
const url = `file:${path.join(__dirname, 'switch-to-iframe.test.html')}`;
const selector = p.selector('iframe');
const inputInIframe = '#input-inside-iframe';
// When
await p
.withBrowser('chromium')
.withOptions({ headless: false })
.withCursor()
.navigateTo(url)
.hover(selector)
.switchToIframe(selector)
.expectThat(inputInIframe)
.hasValue('I am in an iframe')
.click(inputInIframe)
.typeText('foobar')
.expectThat(inputInIframe)
.hasValue('foobar');
// Then
const value = await p.getValueOf(inputInIframe);
expect(value).toBe('foobar');
});
test('should switch to iframe and back to page - chromium', async () => {
// Given
const url = `file:${path.join(__dirname, 'switch-to-iframe.test.html')}`;
const selector = 'iframe';
const inputInIframe = '#input-inside-iframe';
// When
await p
.withBrowser('chromium')
.withOptions({ headless: false })
.withCursor()
.navigateTo(url)
.hover(selector)
.switchToIframe(selector)
.expectThat(inputInIframe)
.hasValue('I am in an iframe')
.click(inputInIframe)
.typeText('foobar')
.switchBackToPage()
.click('input#in-view-port')
.typeText('hey I am back in the page');
// Then
const value = await p.getValueOf('input#in-view-port');
expect(value).toBe('hey I am back in the page');
});
});
;