Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

selenium - How do you disable "navigator.webdriver" in chromedriver?

After hours of searching for methods, I was not able to find any ways that would simply work.

The only way I could find was Setting the "pageLoadingStrategy" capability value to "eager", and then immediately executing some javascript so it could change the navigator.webdriver value before the page was rendered. But then you need to change the value after every request and it's not really reliable.

How do you set this before executing any requests? Is there a flag?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

After looking at the chrome source code for a good while, I finally figured out what flag needs to be used to disable that navigator.webdriver nuisance.

Here is the flag that needs to be used when starting chromedriver. It completely disables "webdriver=true" from even showing up. :)

--disable-blink-features=AutomationControlled

Also here's some more features that can be enabled/disabled.

Features

Enable Flag:
--enable-blink-features=example1,example2,example3

Disable Flag
--disable-blink-features=example1,example2,example3

Hopefully this helps someone who has also come across this problem. Thanks for looking


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...