title: How to unset navigator.webdriver in headless chrome using selenium?
body: <p>How can i make <code>navigator.webdriver</code> disappear in a headless chrome?</p>
  
  <p><code>options.setExperimentalOption("excludeSwitches", Arrays.asList("enable-automation"));</code><br>
  The above line can make <code>navigator.webdriver</code> disappear in a non headless chrome.But it doesn't work with a headless chrome.<br>
  I found <code>evaluateOnNewDocument</code> from <a href="https://github.com/GoogleChrome/puppeteer" rel="nofollow noreferrer">puppeteer</a> that can set that property just before page to load.But how to achieve the same with selenium?</p>
  
  <pre><code>await page.evaluateOnNewDocument(() =&gt; {
    Object.defineProperty(navigator, 'webdriver', {
      get: () =&gt; false,
    });
  });
  </code></pre>