From 51b5d3f77237a33775b3862fd938f533306157b5 Mon Sep 17 00:00:00 2001 From: Luc Gagan Date: Sat, 11 Nov 2023 07:22:53 -0600 Subject: [PATCH] feat: add locator.clear --- README.md | 1 + src/completeTask.ts | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/README.md b/README.md index a35879f..7a4c426 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,7 @@ Certainly! Here's a rephrased version of the provided content, presented in a ma ## Supported Playwright Actions +- `locator.clear` - `locator.click` - `locator.fill` - `locator.getAttribute` diff --git a/src/completeTask.ts b/src/completeTask.ts index eee34da..0f10f09 100644 --- a/src/completeTask.ts +++ b/src/completeTask.ts @@ -157,6 +157,30 @@ export const completeTask = async ( }, }, }, + { + function: async (args: { elementId: string }) => { + await getLocator(args.elementId).clear(); + + return { success: true }; + }, + name: "locator_clear", + description: "Clear the input field.", + parse: (args: string) => { + return z + .object({ + elementId: z.string(), + }) + .parse(JSON.parse(args)); + }, + parameters: { + type: "object", + properties: { + elementId: { + type: "string", + }, + }, + }, + }, { function: async (args: { elementId: string }) => { await getLocator(args.elementId).click();