playwright-fluent
Version:
Fluent API around playwright
43 lines (42 loc) • 1.54 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 SUT = tslib_1.__importStar(require("../index"));
const utils_1 = require("../../../../utils");
describe('get client rectangle of an element handle', () => {
let browser = undefined;
// eslint-disable-next-line @typescript-eslint/no-empty-function
beforeEach(() => { });
afterEach(async () => {
if (browser) {
await browser.close();
}
});
test('should return Client Rectangle - webkit', async () => {
// Given
browser = await playwright_1.webkit.launch({ headless: true });
const browserContext = await browser.newContext({ viewport: null });
const page = await browserContext.newPage();
const url = `file:${path.join(__dirname, 'get-client-rectangle-of-handle.test.html')}`;
await page.goto(url);
await (0, utils_1.sleep)(1000);
// When
const handle = await page.$('#foo');
const result = await SUT.getClientRectangleOfHandle(handle);
// Then
const expectedClientRectangle = {
bottom: 32,
height: 21,
left: 12,
right: 32,
top: 11,
width: 20,
x: 12,
y: 11, // top
};
expect(result).not.toBe(null);
expect(result).toMatchObject(expectedClientRectangle);
});
});
;