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.2 KiB
1.2 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_wait_element | function | go | infra | 1.0.0 | impure | func CdpWaitElement(c *CDPConn, selector string, timeout time.Duration) error | Espera hasta que un selector CSS exista en el DOM. Hace polling con Runtime.evaluate cada 200ms. Retorna nil cuando el elemento aparece o error si se agota el timeout. Util despues de navegacion o acciones que producen cambios dinamicos. |
|
|
false | error_go_core |
|
false | functions/infra/cdp_wait_element.go |
Ejemplo
conn, _ := CdpConnect(9222)
CdpNavigate(conn, "https://example.com")
// Esperar hasta 10 segundos a que aparezca el contenido
if err := CdpWaitElement(conn, ".main-content", 10*time.Second); err != nil {
log.Fatal("Timeout esperando elemento:", err)
}
Notas
Usa document.querySelector(selector) !== null como condicion. Si timeout <= 0 usa 10s por defecto. Los errores de CdpEvaluate durante el polling (pagina cargando) se ignoran y se reintenta en el siguiente ciclo.