Co-authored-by: Alireza <ar.sedghi@gmail.com> Co-authored-by: Dan Rukas <dan.rukas@gmail.com> Co-authored-by: Tang Cheng <45505657+tctco@users.noreply.github.com>
This commit is contained in:
44 files changed
+516
-258
No files matched your search
@@ -17,3 +17,49 @@ export async function simulateClicksOnElement({
|
||||
await locator.click({ delay: 100, position: { x, y } });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Simulates clicks on an element at a normalized point.
|
||||
*
|
||||
* @param locator - The locator to click on.
|
||||
* @param normalizedPoint - The point with x and y coordinates, normalized to the element's bounding box.
|
||||
* @param button - The mouse button to use for the click (default is 'left').
|
||||
*/
|
||||
export async function simulateNormalizedClickOnElement({
|
||||
locator,
|
||||
normalizedPoint,
|
||||
button = 'left',
|
||||
}: {
|
||||
locator: Locator;
|
||||
normalizedPoint: { x: number; y: number };
|
||||
button?: 'left' | 'right' | 'middle';
|
||||
}) {
|
||||
const bBox = await locator.boundingBox();
|
||||
const position = { x: normalizedPoint.x * bBox.width, y: normalizedPoint.y * bBox.height };
|
||||
await locator.click({ delay: 100, position, button });
|
||||
}
|
||||
|
||||
/**
|
||||
* Simulates clicks on an element at normalized points.
|
||||
*
|
||||
* @param locator - The locator to click on.
|
||||
* @param normalizedPoints - An array of points with x and y coordinates, normalized to the element's bounding box.
|
||||
* @param button - The mouse button to use for the click (default is 'left').
|
||||
*/
|
||||
export async function simulateNormalizedClicksOnElement({
|
||||
locator,
|
||||
normalizedPoints,
|
||||
button = 'left',
|
||||
}: {
|
||||
locator: Locator;
|
||||
normalizedPoints: { x: number; y: number }[];
|
||||
button?: 'left' | 'right' | 'middle';
|
||||
}) {
|
||||
for (const normalizedPoint of normalizedPoints) {
|
||||
await simulateNormalizedClickOnElement({
|
||||
locator,
|
||||
normalizedPoint,
|
||||
button,
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user