Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,31 @@ server.tool(
}
);

server.tool(
"clear",
"resets content of the element",
{
...locatorSchema,
text: z.string().describe("Resets content of the element")
},
async ({ by, value, text, timeout = 10000 }) => {
try {
Comment on lines +228 to +232
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Remove unused required "text" input and param from the clear tool.

The tool ignores the provided "text" but still requires it via zod, forcing clients to supply meaningless data and creating API friction.

Apply this diff to drop the unused field and param:

 server.tool(
   "clear",
   "resets content of the element",
   {
-    ...locatorSchema,
-    text: z.string().describe("Resets content of the element")
+    ...locatorSchema
   },
-  async ({ by, value, text, timeout = 10000 }) => {
+  async ({ by, value, timeout = 10000 }) => {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
...locatorSchema,
text: z.string().describe("Resets content of the element")
},
async ({ by, value, text, timeout = 10000 }) => {
try {
...locatorSchema
},
async ({ by, value, timeout = 10000 }) => {
try {
🤖 Prompt for AI Agents
In src/lib/server.js around lines 228 to 232, the clear tool currently declares
and requires a "text" field in the zod schema and function signature but never
uses it; remove the unused "text" from the schema, its .describe(), and from the
async function parameter list (including defaulting and any references), and
update any callsites and TypeScript types/usages that expect that parameter so
clients are no longer forced to provide meaningless data.

const driver = getDriver();
const locator = getLocator(by, value);
const element = await driver.wait(until.elementLocated(locator), timeout);
await element.clear();
Comment on lines +235 to +236
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Wait for element to be visible and enabled before clearing.

elementLocated only ensures presence in the DOM; clear() can fail on hidden/disabled elements. Guard with visibility/enabled waits for robustness.

-      const element = await driver.wait(until.elementLocated(locator), timeout);
-      await element.clear();
+      const element = await driver.wait(until.elementLocated(locator), timeout);
+      await driver.wait(until.elementIsVisible(element), timeout);
+      await driver.wait(until.elementIsEnabled(element), timeout);
+      await element.clear();
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const element = await driver.wait(until.elementLocated(locator), timeout);
await element.clear();
const element = await driver.wait(until.elementLocated(locator), timeout);
await driver.wait(until.elementIsVisible(element), timeout);
await driver.wait(until.elementIsEnabled(element), timeout);
await element.clear();
🤖 Prompt for AI Agents
In src/lib/server.js around lines 235-236, the code locates an element then
calls clear() but only ensures presence in the DOM; change the flow to wait for
the element to be visible and enabled before clearing. After obtaining the
element with driver.wait(until.elementLocated(locator), timeout), call
driver.wait(until.elementIsVisible(element), timeout) and
driver.wait(until.elementIsEnabled(element), timeout) (or an equivalent combined
visibility/enabled check) and only then call element.clear(); this makes clear()
robust against hidden/disabled elements.

return {
content: [{ type: 'text', text: 'Element value reset' }]
};
} catch (e) {
return {
content: [{ type: 'text', text: `Error in reset of the element: ${e.message}` }]
};
}
}
);


server.tool(
"get_element_text",
"gets the text() of an element",
Expand Down