I have a slice containing a list of terms, and I want to search for each term in a certain search engine page, so I am doing this:
func risk(slice []string) chromedp.Tasks {
return chromedp.Tasks{
chromedp.Navigate("https://testpage"),
chromedp.WaitVisible("#query_box", chromedp.ByID),
chromedp.ActionFunc(func(context.Context, cdp.Executor) error {
for _, element := range slice[2:] {
fmt.Println(element)
chromedp.SendKeys("#query_box", element, chromedp.ByID)
chromedp.Click("#searchButton", chromedp.ByID),
}
return nil
}),
}
}
main
err = c.Run(ctxt, risk(items))
if err != nil {
log.Fatal(err)
}
ActionFunc
ActionFunc
return nilActionFuncnil
chromedp.Tasks