Search code examples
javaseleniumselenium-webdriverselenium-chromedriverwebdrivermanager-java

Have WebDriverManager Download to Specific Directory


I understand that the following line of code places the latest chromedriver file in ~/.cache/selenium...

WebDriverManager.chromedriver().setup();

My question: Is there a way to configure this to download the file to a specific directory?

As an example, say I have a directory named "MyChromeDriver". I would like WebDriverManager to place the chromedriver file inside "MyChromeDriver" without all the extra sub-directories.

Thank you in advance!


Solution

  • Invoke WebDriverManager as follows:

    WebDriverManager.chromedriver().cachePath("MyChromeDriver").avoidOutputTree().setup();