Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Evaluating js function: encountered an undefined value #658

Closed
GAZ082 opened this issue Jul 9, 2020 · 2 comments · Fixed by #816
Closed

Evaluating js function: encountered an undefined value #658

GAZ082 opened this issue Jul 9, 2020 · 2 comments · Fixed by #816

Comments

@GAZ082
Copy link

GAZ082 commented Jul 9, 2020

What versions are you running?

github.com/chromedp/chromedp v0.5.3
Google Chrome 83.0.4103.116
go version go1.14.4 linux/amd64

What did you do? Include clear steps.

  1. Go to the website.
  2. Login.
  3. Wait page to load.
  4. chromedp.EvaluateAsDevTools("Submit('EX');", &x),

What did you expect to see?

A file should download.

What did you see instead?

encountered an undefined value

Code snippet:

	err := chromedp.Run(ctx,
		page.SetDownloadBehavior("allow").WithDownloadPath("/home/xxx/projects/website/"),
		chromedp.Navigate("https://xxxx/Login.aspx"),
		chromedp.WaitVisible("footer", chromedp.ByID),
		chromedp.SendKeys("#ctl00_cphBarra_login_UserName", "xxx", chromedp.ByID),
		chromedp.SendKeys("#ctl00_cphBarra_login_Password", "xxxx", chromedp.ByID),
		chromedp.Click("ctl00_cphBarra_login_Login"),
		chromedp.WaitVisible("footer", chromedp.ByID),
		chromedp.Navigate("https://xxxx/dddd"),
		chromedp.WaitVisible("footer", chromedp.ByID),
		chromedp.Sleep(5*time.Second),
		chromedp.EvaluateAsDevTools("Submit('EX');", &x),
	)

Also tried:
chromedp.Click("#TablaBotones > tbody > tr > td:nth-child(4)", chromedp.ByJSPath),
which is the element that has attached the JS function but does not work (the JS is called on a onmouseup event tho, could not find something similar in chromedp).

Calling the function in the console works, even in the Chrome window chromedp opens (i'm not using headless for testing).

Any tips? I'd hate to go to the nodejs way.

Thanks!

@GAZ082 GAZ082 changed the title Evaluating js function: encountered exception 'Uncaught' (0:0) Evaluating js function: encountered an undefined value Jul 9, 2020
@leafney
Copy link

leafney commented Apr 1, 2021

look at this #526

@ZekeLu
Copy link
Member

ZekeLu commented May 8, 2021

As @leafney pointed out, this is a duplicate of #526.

Apply the changes in #816, you can address the issue like this:

-chromedp.EvaluateAsDevTools("Submit('EX');", &x),
+chromedp.EvaluateAsDevTools("Submit('EX');", nil),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants