I\'ve been testing out Selenium with Chromedriver and I noticed that some pages can detect that you\'re using Selenium even though there\'s no automation at all. Even when I
Additionally to the great answer of @Erti-Chris Eelmaa - there's annoying window.navigator.webdriver
and it is read-only. Event if you change the value of it to false
it will still have true
. Thats why the browser driven by automated software can still be detected.
MDN
The variable is managed by the flag --enable-automation
in chrome. The chromedriver launches chrome with that flag and chrome sets the window.navigator.webdriver
to true
. You can find it here. You need to add to "exclude switches" the flag. For instance (golang):
package main
import (
"github.com/tebeka/selenium"
"github.com/tebeka/selenium/chrome"
)
func main() {
caps := selenium.Capabilities{
"browserName": "chrome",
}
chromeCaps := chrome.Capabilities{
Path: "/path/to/chrome-binary",
ExcludeSwitches: []string{"enable-automation"},
}
caps.AddChrome(chromeCaps)
wd, err := selenium.NewRemote(caps, fmt.Sprintf("http://localhost:%d/wd/hub", 4444))
}