feat(browserTool): Implement hover action (#2368)

* Implement hover action for the browser action tool

* Update snapshots
This commit is contained in:
Marco Quinten 2025-04-07 20:35:14 +07:00 committed by GitHub
parent fff8fdd3f3
commit f5a4b425da
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 17 additions and 4 deletions

View file

@ -2714,6 +2714,9 @@ Parameters:
* launch: Launch a new Puppeteer-controlled browser instance at the specified URL. This **must always be the first action**.
- Use with the \`url\` parameter to provide the URL.
- Ensure the URL is valid and includes the appropriate protocol (e.g. http://localhost:3000/page, file:///path/to/file.html, etc.)
* hover: Move the cursor to a specific x,y coordinate.
- Use with the \`coordinate\` parameter to specify the location.
- Always move to the center of an element (icon, button, link, etc.) based on coordinates derived from a screenshot.
* click: Click at a specific x,y coordinate.
- Use with the \`coordinate\` parameter to specify the location.
- Always click in the center of an element (icon, button, link, etc.) based on coordinates derived from a screenshot.
@ -2727,7 +2730,7 @@ Parameters:
- Example: \`<action>close</action>\`
- url: (optional) Use this for providing the URL for the \`launch\` action.
* Example: <url>https://example.com</url>
- coordinate: (optional) The X and Y coordinates for the \`click\` action. Coordinates should be within the **900x600** resolution.
- coordinate: (optional) The X and Y coordinates for the \`click\` and \`hover\` actions. Coordinates should be within the **900x600** resolution.
* Example: <coordinate>450,300</coordinate>
- size: (optional) The width and height for the \`resize\` action.
* Example: <size>1280,720</size>
@ -3629,6 +3632,9 @@ Parameters:
* launch: Launch a new Puppeteer-controlled browser instance at the specified URL. This **must always be the first action**.
- Use with the \`url\` parameter to provide the URL.
- Ensure the URL is valid and includes the appropriate protocol (e.g. http://localhost:3000/page, file:///path/to/file.html, etc.)
* hover: Move the cursor to a specific x,y coordinate.
- Use with the \`coordinate\` parameter to specify the location.
- Always move to the center of an element (icon, button, link, etc.) based on coordinates derived from a screenshot.
* click: Click at a specific x,y coordinate.
- Use with the \`coordinate\` parameter to specify the location.
- Always click in the center of an element (icon, button, link, etc.) based on coordinates derived from a screenshot.
@ -3642,7 +3648,7 @@ Parameters:
- Example: \`<action>close</action>\`
- url: (optional) Use this for providing the URL for the \`launch\` action.
* Example: <url>https://example.com</url>
- coordinate: (optional) The X and Y coordinates for the \`click\` action. Coordinates should be within the **1280x800** resolution.
- coordinate: (optional) The X and Y coordinates for the \`click\` and \`hover\` actions. Coordinates should be within the **1280x800** resolution.
* Example: <coordinate>450,300</coordinate>
- size: (optional) The width and height for the \`resize\` action.
* Example: <size>1280,720</size>

View file

@ -15,6 +15,9 @@ Parameters:
* launch: Launch a new Puppeteer-controlled browser instance at the specified URL. This **must always be the first action**.
- Use with the \`url\` parameter to provide the URL.
- Ensure the URL is valid and includes the appropriate protocol (e.g. http://localhost:3000/page, file:///path/to/file.html, etc.)
* hover: Move the cursor to a specific x,y coordinate.
- Use with the \`coordinate\` parameter to specify the location.
- Always move to the center of an element (icon, button, link, etc.) based on coordinates derived from a screenshot.
* click: Click at a specific x,y coordinate.
- Use with the \`coordinate\` parameter to specify the location.
- Always click in the center of an element (icon, button, link, etc.) based on coordinates derived from a screenshot.
@ -28,7 +31,7 @@ Parameters:
- Example: \`<action>close</action>\`
- url: (optional) Use this for providing the URL for the \`launch\` action.
* Example: <url>https://example.com</url>
- coordinate: (optional) The X and Y coordinates for the \`click\` action. Coordinates should be within the **${args.browserViewportSize}** resolution.
- coordinate: (optional) The X and Y coordinates for the \`click\` and \`hover\` actions. Coordinates should be within the **${args.browserViewportSize}** resolution.
* Example: <coordinate>450,300</coordinate>
- size: (optional) The width and height for the \`resize\` action.
* Example: <size>1280,720</size>

View file

@ -73,7 +73,7 @@ export async function browserActionTool(
await cline.browserSession.launchBrowser()
browserActionResult = await cline.browserSession.navigateToUrl(url)
} else {
if (action === "click") {
if (action === "click" || action === "hover") {
if (!coordinate) {
cline.consecutiveMistakeCount++
pushToolResult(await cline.sayAndCreateMissingParamError("browser_action", "coordinate"))
@ -112,6 +112,9 @@ export async function browserActionTool(
case "click":
browserActionResult = await cline.browserSession.click(coordinate!)
break
case "hover":
browserActionResult = await cline.browserSession.hover(coordinate!)
break
case "type":
browserActionResult = await cline.browserSession.type(text!)
break
@ -133,6 +136,7 @@ export async function browserActionTool(
switch (action) {
case "launch":
case "click":
case "hover":
case "type":
case "scroll_down":
case "scroll_up":