Files
fn_registry/functions/browser/chrome_launch.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.5 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
chrome_launch function go browser 1.0.0 impure func ChromeLaunch(opts ChromeLaunchOpts) (int, error) Lanza Google Chrome con remote debugging habilitado en el puerto indicado. Busca chrome.exe en PATH (WSL2) o en rutas conocidas de Windows. Espera hasta 15s a que el puerto CDP este listo antes de retornar. Retorna el PID del proceso.
chrome
cdp
browser
automation
wsl2
headless
false error_go_core
fmt
net
os
os/exec
time
true
TestFindChrome
TestChromeLaunchAndConnect
functions/browser/chrome_launch_test.go functions/browser/chrome_launch.go

Ejemplo

pid, err := ChromeLaunch(ChromeLaunchOpts{
    Port:        9222,
    UserDataDir: "/tmp/chrome-cdp",
    Headless:    true,
})
if err != nil {
    log.Fatal(err)
}
defer CdpClose(nil, pid)

Notas

Busca Chrome en este orden:

  1. chrome.exe en PATH (disponible en WSL2 si Windows lo tiene en PATH)
  2. google-chrome / chromium-browser / chromium (Linux nativo)
  3. /mnt/c/Program Files/Google/Chrome/Application/chrome.exe
  4. /mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe

Los flags aplicados desactivan funcionalidades de red y actualizacion en segundo plano para entornos de automatizacion. En modo headless se agrega --headless=new --disable-gpu.

El struct ChromeLaunchOpts se define en el mismo archivo.