What is the cdc variable in chromedriver?

tonetheman profile image Tony Colston ・2 min read

I saw this thread on reddit and wondered myself WTF is the cdc variable in chromedriver


So what is it and why would you even care?

It is a variable that shows up in document when you are using chromedriver. With one tiny subtle thing... if you just run driver.get and do not interact with the page in Selenium the variable does not show up...

Websites that know about it can detect that they are being called/displayed from an automated browser.

You can see it if you look at document["$cdc_asdjflasutopfhvcZLmcfl_"] in javascript. You can verify this by adding this code to a Selenium script in Python.

print(driver.execute_script("return document['$cdc_asdjflasutopfhvcZLmcfl_']"))

This will always return something if you are using chromedriver (or at least as of chromedriver 75).

Where does that variable come from? It is code that is embedded in chromedriver. You can find it yourself in the chromium source code. https://github.com/chromium/chromium/tree/master/chrome/test/chromedriver

What if you want to change it so your Selenium scripts will be undetected? The not so easy way is to compile it yourself (but you get points for being a nerd).

The much easier way is to change that variable is to edit your chromedriver executable. See that link below for a reasonable way to do that. Be aware when you change the executable it will trigger a Win10 virus scan the first time you run it again after you hacked it.

I have used this with vim on Windows 10 and it works.


Posted on by:

tonetheman profile

Tony Colston


wanna be gamedev ... all around nerd and dev


Editor guide