Files
egutierrez 47fac22230 chore: auto-commit (799 archivos)
- .claude/CLAUDE.md
- .claude/commands/subagentes.md
- .claude/rules/INDEX.md
- .mcp.json
- bash/functions/cybersecurity/analyze_dns.md
- bash/functions/cybersecurity/audit_http_headers.md
- bash/functions/cybersecurity/audit_ssh_config.md
- bash/functions/cybersecurity/check_firewall.md
- bash/functions/cybersecurity/detect_suspicious_users.md
- bash/functions/cybersecurity/encrypt_file.md
- ...

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-14 00:28:20 +02:00

47 lines
1.8 KiB
Markdown

---
name: cdp_click_text
kind: function
lang: go
domain: browser
version: 0.1.0
purity: impure
signature: "func CdpClickText(c *CDPConn, text string, opts FindByTextOpts) error"
description: "Localiza el primer elemento cuyo innerText matchea el texto dado y le hace click. Composicion de CdpFindByText + CdpClick. Mas robusto que click por selector CSS porque el texto visible cambia menos que la estructura del DOM."
tags: [browser, cdp, click, locator, accessibility, pendiente-usar]
uses_functions:
- cdp_find_by_text_go_browser
- cdp_click_go_browser
uses_types: []
returns: []
returns_optional: false
error_type: error_go_core
imports: []
example: |
c, _ := browser.CdpConnect(9222)
defer browser.CdpClose(c, 0)
err := browser.CdpClickText(c, "Sign in", browser.FindByTextOpts{Tag: "button"})
if err != nil {
log.Fatal(err)
}
tested: true
tests: ["TestCdpClickText_returnsErrorOnEmpty"]
test_file_path: "functions/browser/cdp_click_text_test.go"
file_path: "functions/browser/cdp_click_text.go"
notes: |
- Devuelve error si no encuentra ningun elemento con ese texto — fail-loud, no falso positivo.
- Reusa la heuristica leafmost de CdpFindByText (click va al elemento mas interno con el texto).
- Para multiples coincidencias (ej. dos botones "OK"), pasar opts.Tag o usar un texto mas especifico.
documentation: |
Patron `getByText(...).click()` de Playwright. Reduce mantenimiento de
tests e2e: cuando el frontend renombra clases CSS o reordena DOM, el
test sigue funcionando si el texto visible no cambia.
params:
- name: c
desc: "Conexion CDP activa."
- name: text
desc: "Texto del elemento a clickar."
- name: opts
desc: "FindByTextOpts (mismos campos que CdpFindByText)."
output: "nil si click OK, error con descripcion si no encuentra elemento o click falla."
---