package browser import "fmt" // CdpClickText combina CdpFindByText + CdpClick: localiza el primer elemento // con `text` y le hace click. Util para tests/scraping sin depender de // selectores CSS fragiles. // // Si no encuentra ningun elemento con ese texto, retorna error claro // (no falso negativo silencioso). func CdpClickText(c *CDPConn, text string, opts FindByTextOpts) error { if c == nil { return fmt.Errorf("cdp click text: conexion nula") } sel, err := CdpFindByText(c, text, opts) if err != nil { return fmt.Errorf("cdp click text: %w", err) } if sel == "" { return fmt.Errorf("cdp click text: no se encontro elemento con texto %q (tag=%q exact=%v)", text, opts.Tag, opts.Exact) } if err := CdpClick(c, sel); err != nil { return fmt.Errorf("cdp click text: click sobre %q: %w", sel, err) } return nil }