playwright-fluent
Version:
Fluent API around playwright
36 lines (35 loc) • 1.48 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const path = tslib_1.__importStar(require("path"));
const playwright_1 = require("playwright");
const dom_actions_1 = require("../../dom-actions");
const SUT = tslib_1.__importStar(require("../index"));
describe('get current url', () => {
let browser = undefined;
// eslint-disable-next-line @typescript-eslint/no-empty-function
beforeEach(() => { });
afterEach(async () => {
if (browser) {
await browser.close();
}
});
test('should return an error - chromium', async () => {
// Given
browser = await playwright_1.chromium.launch({ headless: true });
const browserContext = await browser.newContext({ viewport: null });
const page = await browserContext.newPage();
await (0, dom_actions_1.showMousePosition)(page);
const url = `file:${path.join(__dirname, 'get-current-url.test.html')}`;
await page.goto(url);
const linkSelector = '#foobar';
// When I click on a link that opens a new browser tab
await page.click(linkSelector);
// And I close the previous browser tab
await page.close();
// Then
const result = await SUT.getCurrentUrl(page);
const expectedResult = 'Error: page.evaluate: Target page, context or browser has been closed';
expect(result).toBe(expectedResult);
});
});
;