title: Selenium Java: How to get current ChromeDriver instance's user directory and version using ChromeCapabilities
body: <p>I want to know the following information from my current running ChromeDriver:
  <li>exact temporary user-data folder that ChromeDriver created by default
  <li>the driver version</p>
  
  <p>According to <a href="https://sites.google.com/a/chromium.org/chromedriver/capabilities" rel="nofollow noreferrer">this</a> page, It should be part of the ChromeDriver's returned capabilities:<a href="https://i.stack.imgur.com/tywbh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tywbh.png" alt="enter image description here"></a></p>
  
  <p><strong>What I tried so far:</strong></p>
  
  <pre><code>Capabilities caps = DesiredCapabilities.chrome();
  System.out.println(caps.getCapability("userDataDir"));
  System.out.println(caps.getCapability("chrome.chromedriverVersion"));
  </code></pre>
  
  <p>Both are giving me null. I do know that I'm not manually setting the ChromeOptions "--user-data-dir" but still, I know that ChromeDriver will use a certain directory by default. </p>
  
  <p>Same goes with the version, It makes sense that we can retrieve the current driver's version at will right?</p>
  
  <p>What am I missing here?</p>
  
  <p>Thanks in advance!</p>
  
  <p><strong>UPDATE 1:</strong><br>
  I'm calling the code above right before passing the <code>caps</code> instance as a parameter to the ChromeDriver constructor.</p>
  
  <p>Here's a slightly more insightful snippet:</p>
  
  <pre><code>public class Driver implements WebDriver {
  
     private WebDriver webDriver;
     private Capabilities caps;
  
     public Driver(){
        caps = DesiredCapabilities.chrome();
        caps.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
        caps.setCapability(CapabilityType.SUPPORTS_APPLICATION_CACHE, true);
        caps.setCapability(CapabilityType.SUPPORTS_ALERTS, true);
        caps.setCapability(CapabilityType.SUPPORTS_FINDING_BY_CSS, true);
  
        //Am I not doing this correctly?
        System.out.println(caps.getCapability("userDataDir"));
        System.out.println(caps.getCapability("chrome.chromedriverVersion"));
  
        webDriver = new ChromeDriver(caps);
     }
  }
  </code></pre>
  
  <p><strong>UPDATE 2:</strong>
  Regarding the version number, I realized that whenever I do</p>
  
  <pre><code>Capabilities caps = DesiredCapabilities.chrome();
  </code></pre>
  
  <p>the DesiredCapabilities class is passing a blank string as a parameter to the version number. </p>
  
  <p><a href="https://i.stack.imgur.com/OgjUk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OgjUk.png" alt="enter image description here"></a><br>
  <a href="https://i.stack.imgur.com/hMtQy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hMtQy.png" alt="enter image description here"></a></p>
  
  <p>With that said, is there any way I can get the current chrome driver version (boxed below)? I know this information is stored somewhere but I do not know how to get it. </p>
  
  <p><a href="https://i.stack.imgur.com/d1y27.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/d1y27.png" alt="enter image description here"></a></p>
  
  <p>As for the temporary user-data folder, I still have no idea how to get it even after watching the capabilities and the webdriver object created.</p>
  
  <p>Appreciate the help!</p>