Skip to content

Commit

Permalink
feat: add locator.textContent
Browse files Browse the repository at this point in the history
  • Loading branch information
lucgagan committed Nov 12, 2023
1 parent 372252d commit d03fcd7
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ Certainly! Here's a rephrased version of the provided content, presented in a ma
- `locator.isEditable`
- `locator.isEnabled`
- `locator.isVisible`
- `locator.textContent`
- `locator.uncheck`
- `page.goto`
Expand Down
34 changes: 31 additions & 3 deletions src/completeTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,30 @@ export const completeTask = async (
},
},
},
{
function: async (args: { elementId: string }) => {
return {
textContent: await getLocator(args.elementId).textContent(),
};
},
name: "locator_textContent",
description: "Returns the node.textContent.",
parse: (args: string) => {
return z
.object({
elementId: z.string(),
})
.parse(JSON.parse(args));
},
parameters: {
type: "object",
properties: {
elementId: {
type: "string",
},
},
},
},
{
function: (args: { elementId: string }) => {
return getLocator(args.elementId).inputValue();
Expand Down Expand Up @@ -274,10 +298,13 @@ export const completeTask = async (
},
{
function: async (args: { elementId: string }) => {
return { isEditable: await getLocator(args.elementId).isEditable() };
return {
isEditable: await getLocator(args.elementId).isEditable(),
};
},
name: "locator_isEditable",
description: "Returns whether the element is editable. Element is considered editable when it is enabled and does not have readonly property set.",
description:
"Returns whether the element is editable. Element is considered editable when it is enabled and does not have readonly property set.",
parse: (args: string) => {
return z
.object({
Expand All @@ -299,7 +326,8 @@ export const completeTask = async (
return { isEnabled: await getLocator(args.elementId).isEnabled() };
},
name: "locator_isEnabled",
description: "Returns whether the element is enabled. Element is considered enabled unless it is a <button>, <select>, <input> or <textarea> with a disabled property.",
description:
"Returns whether the element is enabled. Element is considered enabled unless it is a <button>, <select>, <input> or <textarea> with a disabled property.",
parse: (args: string) => {
return z
.object({
Expand Down

0 comments on commit d03fcd7

Please sign in to comment.