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

'DOM.scrollIntoViewIfNeeded' wasn't found #881

Closed
FournyP opened this issue Jul 17, 2021 · 6 comments
Closed

'DOM.scrollIntoViewIfNeeded' wasn't found #881

FournyP opened this issue Jul 17, 2021 · 6 comments

Comments

@FournyP
Copy link

FournyP commented Jul 17, 2021

What versions are you running?

$ go list -m github.com/chromedp/chromedp
github.com/chromedp/chromedp v0.7.4
$ google-chrome --version
Chromium 75.0.3770.142
$ go version
go version go1.16.6 windows/amd64

What did you do? Include clear steps.

Hello everyone, I have a problem with chromedp

I try to access to a web page thanks test and I got the error : 'DOM.scrollIntoViewIfNeeded' wasn't found (-32601)

My code :

// Emulate a mobile
err := chromedp.Emulate(device.IPhoneX).Do(c)
if err != nil {
   return err
}

// Go to register endpoint
err = chromedp.Navigate(REGISTER_ENDPOINT).Do(c)
if err != nil {
   return err
}

// Wait the cookie modal
chromedp.WaitVisible(COOKIE_BTN_SELECTOR).Do(c)
if err != nil {
   return err
}

// Accept cookies
err = chromedp.Click(COOKIE_BTN_SELECTOR).Do(c)
if err != nil {
   return err
}

I have update the dependencies and after that, my code return me this error, it worked before that.
The error appear when I run the "accept cookies" phase

What did you expect to see?

No error, like before

What did you see instead?

An error 'DOM.scrollIntoViewIfNeeded' wasn't found

Thanks for your help

Have a good day

@FournyP
Copy link
Author

FournyP commented Jul 17, 2021

I have try to use scrollIntoViewIfNeeded func in a page with my Chromium and that work

A example to show it work :
Image

@ZekeLu
Copy link
Member

ZekeLu commented Jul 17, 2021

Please upgrade your chromium. DOM.scrollIntoViewIfNeeded is a CDP command. It is needed in chromedp v0.7.4. Sorry that when I used it, I did not check which version of chromium started to support it, and failed to mention it in the release notes.

@ZekeLu
Copy link
Member

ZekeLu commented Jul 17, 2021

Just read #877 (comment). IIRC, chromedp.Flag("enable-automation", false) should work in a recent version of chromium. Please have a try and let me know the result. Thank you!

@FournyP
Copy link
Author

FournyP commented Jul 17, 2021

Hello @ZekeLu

I have installed the version 91.0.* version of chromium

The enable-automation didn't work :
Image

Google use the window.navigator.webdriver value to identify when the browser is controlled

Here the documentation of this :
https://developer.mozilla.org/en-US/docs/Web/API/Navigator/webdriver

That work in the 75.0.* version

Do you know why ?

Have a good day and thanks you for your quick reply

@ZekeLu
Copy link
Member

ZekeLu commented Jul 17, 2021

@FournyP I have searched the commit history of chromium, and I have a bad news. window.navigator.webdriver is set to true if any of the following switches is contained in the command line since 79.0.3922.0:

  • enable-automation
  • headless
  • remote-debugging-pipe
  • remote-debugging-port (or remote-debugging-port=0 since 86.0.4199.0)

And DOM.scrollIntoViewIfNeeded is added in 82.0.4056.0. So there is not an easy way to workaround the issue.

Here are the references:

So after 86.0.4199.0, we have to set the following flags to make window.navigator.webdriver be false:

// Set enable-automation to false alone is not enough to make
// `window.navigator.webdriver` be false since 79.0.3922.0.
// Headless mode should be disabled too, which is not acceptable
// for automation in my opinion.
opts := append(chromedp.DefaultExecAllocatorOptions[:],
	chromedp.Flag("enable-automation", false),
	chromedp.Flag("headless", false),
	// any port other than "0" will work since 86.0.4199.0
	chromedp.Flag("remote-debugging-port", "9222"),
)

A better workaround is suggested by @pmurley in #557 (comment).

@FournyP
Copy link
Author

FournyP commented Jul 17, 2021

@ZekeLu

No problem, thank you for your reply

Have a good day

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

No branches or pull requests

2 participants