Skip to content

Commit be82322

Browse files
committed
feat: add locator.boundingBox
1 parent 9e9413d commit be82322

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ Certainly! Here's a rephrased version of the provided content, presented in a ma
120120
121121
## Supported Playwright Actions
122122
123+
- `locator.boundingBox`
123124
- `locator.clear`
124125
- `locator.click`
125126
- `locator.count`

src/completeTask.ts

+22
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,28 @@ export const completeTask = async (
157157
},
158158
},
159159
},
160+
{
161+
function: async (args: { elementId: string }) => {
162+
return await getLocator(args.elementId).boundingBox();
163+
},
164+
name: "locator_boundingBox",
165+
description: "This method returns the bounding box of the element matching the locator, or null if the element is not visible. The bounding box is calculated relative to the main frame viewport - which is usually the same as the browser window. The returned object has x, y, width, and height properties.",
166+
parse: (args: string) => {
167+
return z
168+
.object({
169+
elementId: z.string(),
170+
})
171+
.parse(JSON.parse(args));
172+
},
173+
parameters: {
174+
type: "object",
175+
properties: {
176+
elementId: {
177+
type: "string",
178+
},
179+
},
180+
},
181+
},
160182
{
161183
function: async (args: { elementId: string }) => {
162184
await getLocator(args.elementId).clear();

0 commit comments

Comments
 (0)