add09c2faa
10 funciones Go en infra/ para controlar Chrome via Chrome DevTools Protocol: chrome_launch, cdp_connect, cdp_navigate, cdp_evaluate, cdp_screenshot, cdp_click, cdp_type_text, cdp_wait_element, cdp_get_html, cdp_close. WebSocket RFC 6455 implementado sin dependencias externas. Incluye tests de integración con Chrome real. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1.4 KiB
1.4 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_connect | function | go | infra | 1.0.0 | impure | func CdpConnect(port int) (*CDPConn, error) | Se conecta al endpoint CDP en localhost:{port}. Obtiene el webSocketDebuggerUrl via HTTP /json/version, realiza el handshake WebSocket RFC 6455 sobre TCP puro (sin dependencias externas) y retorna una CDPConn lista para usar. Inicia goroutine de lectura de mensajes. |
|
false | error_go_core |
|
true |
|
functions/infra/chrome_launch_test.go | functions/infra/cdp_connect.go |
Ejemplo
conn, err := CdpConnect(9222)
if err != nil {
log.Fatal(err)
}
defer CdpClose(conn, 0)
Notas
El WebSocket se implementa desde cero usando net.Dial + handshake HTTP Upgrade + framing RFC 6455. Esto evita dependencias externas. Solo soporta frames no fragmentados (suficiente para CDP que envia mensajes completos).
El struct CDPConn y toda la infraestructura WebSocket/CDP se define en cdp_conn.go dentro del mismo paquete infra.
La goroutine readLoop enruta respuestas a channels por ID de mensaje. Los eventos CDP sin ID son ignorados (las funciones que necesitan eventos usan polling).