I'm attempting to use chromedp to log into a dashboard. the action on the form is action="javascript:void(0);"
. When submit is pressed a number of JS functions kick off, with the end result producing the url; the action updated and the submit process continues.
looking at the log, chromedp is using "javascript:void(0);"
as the action, so the process is in a continuous loop looking app-sidebar-navigation-menu__item__label
. login() is the relevant function:
func login(cfg *config, url, username, password string, res *string) chromedp.Tasks {
return chromedp.Tasks{
chromedp.Navigate(url),
chromedp.WaitVisible(#Email, chromedp.ByID),
chromedp.WaitVisible(#Password, chromedp.ByID),
chromedp.SendKeys(#Email, username, chromedp.ByID),
chromedp.SendKeys(#Password, password, chromedp.ByID),
chromedp.Submit(#Email, chromedp.ByID),
chromedp.WaitVisible(.app-sidebar-navigation-menu__item__label, chromedp.BySearch),
chromedp.Click(.app-sidebar-navigation-menu__item__label, chromedp.BySearch),
chromedp.Text(.app-sidebar-navigation-menu__item__label, res, chromedp.BySearch),
}
}
I tried to add a sleep(), but I don't think I'm using it in the correct way:
...
chromedp.Submit(#Email, chromedp.ByID, chromedp.After(func(i context.Context, n ...*cdp.Node) error {
chromedp.Sleep(5 * time.Second)
return nil
})),
...
I do plan to take a look at chromedp.ListenTarget
to see if that's a reasonable route, but I'm hoping this is a straightforward solution (and it not, Id need some help with ListenTarget);
I also opened this as an issue on chromedp's github repo; still waiting on a comment.