From 00ccde2570374799f98e28543903c19a4ecf675a Mon Sep 17 00:00:00 2001 From: Luc Gagan Date: Sat, 11 Nov 2023 07:13:59 -0600 Subject: [PATCH] feat: add locator.click --- README.md | 1 + src/completeTask.ts | 24 ++++++++++++++++++++++++ src/errors.ts | 2 +- src/index.ts | 2 +- 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7495688..a35879f 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.click` - `locator.fill` - `locator.getAttribute` - `locator.innerHTML` diff --git a/src/completeTask.ts b/src/completeTask.ts index 0a51ef0..eee34da 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).click(); + + return { success: true }; + }, + name: "locator_click", + description: "Click an element.", + parse: (args: string) => { + return z + .object({ + elementId: z.string(), + }) + .parse(JSON.parse(args)); + }, + parameters: { + type: "object", + properties: { + elementId: { + type: "string", + }, + }, + }, + }, { function: async (args: { value: string; elementId: string }) => { await getLocator(args.elementId).fill(args.value); diff --git a/src/errors.ts b/src/errors.ts index 792f7f5..4886c45 100644 --- a/src/errors.ts +++ b/src/errors.ts @@ -1,4 +1,4 @@ -abstract class AutoPlaywrightError extends Error { +export abstract class AutoPlaywrightError extends Error { public constructor(message?: string) { super(message); this.name = new.target.name; diff --git a/src/index.ts b/src/index.ts index 1fe8cd1..69e5235 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,2 +1,2 @@ export { auto } from "./auto"; -export { UnimplementedError } from "./errors"; +export { AutoPlaywrightError } from "./errors";