Files
fn_registry/functions/browser/cdp_click.md
T
egutierrez 87e8f33b01 fix: corregir lang y file_path en frontmatter de funciones existentes
Normaliza lang: typescript → ts en funciones frontend y corrige file_path de functions/infra/ → functions/browser/ en funciones CDP. Actualiza referencias cn_typescript_core → cn_ts_core.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 03:23:20 +02:00

1.3 KiB

name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, tested, tests, test_file_path, file_path
name kind lang domain version purity signature description tags uses_functions uses_types returns returns_optional error_type imports tested tests test_file_path file_path
cdp_click function go browser 1.0.0 impure func CdpClick(c *CDPConn, selector string) error Hace click en el primer elemento que coincide con el selector CSS. Obtiene coordenadas del centro via getBoundingClientRect, hace scroll al elemento y despacha eventos mousedown+mouseup via Input.dispatchMouseEvent.
chrome
cdp
browser
automation
click
dom
devtools
cdp_connect_go_browser
cdp_evaluate_go_browser
false error_go_core
fmt
strconv
strings
false
functions/browser/cdp_click.go

Ejemplo

conn, _ := CdpConnect(9222)
CdpNavigate(conn, "https://example.com")

// Click en el primer enlace
if err := CdpClick(conn, "a"); err != nil {
    log.Fatal(err)
}

// Click en boton por ID
if err := CdpClick(conn, "#submit-btn"); err != nil {
    log.Fatal(err)
}

Notas

El selector sigue la sintaxis CSS estandar (IDs, clases, atributos, pseudo-selectores). El elemento debe ser visible en el DOM en el momento del click. Si no se encuentra, retorna error inmediatamente sin esperar — combinar con CdpWaitElement para elementos dinamicos.