Files
bytedance--flowgram.ai/e2e/fixed-layout/utils/index.ts
T
wehub-resource-sync 0232b4e2bb
CI / build (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:09:51 +08:00

35 lines
786 B
TypeScript

/**
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
* SPDX-License-Identifier: MIT
*/
import type { Locator } from '@playwright/test';
/**
* @param {import('@playwright/test').Locator} locator
*/
export async function getOffsetByLocator(locator: Locator) {
return locator.evaluate((el) => {
const rect = el.getBoundingClientRect();
const left = rect.left;
const top = rect.top;
const width = rect.width;
const height = rect.height;
return {
left,
top,
width,
height,
centerX: left + width / 2,
centerY: top + height / 2,
right: left + width,
bottom: top + height,
};
});
}
export function cssEscape(str: string) {
return str.replace(/([ !"#$%&'()*+,.\/:;<=>?@[\]^`{|}~])/g, '\\$1');
}