Load Chrome Profile using Selenium WebDriver using java Load Chrome Profile using Selenium WebDriver using java google-chrome google-chrome

Load Chrome Profile using Selenium WebDriver using java


This is an old question, but I was still having a problem getting it to work so I did some more research to understand what was happening. The answer from @PrashanthSams is correct, but I was incorrectly adding \Default to the end of the profile path

I found that Chrome appends \Default to the profile path specified in the user-data-dir. So if your profile path is specified as:

user-data-dir=C:\Users\user_name\AppData\Local\Google\Chrome\User Data\Default\

it will append \Default and you will end up at:

C:\Users\user_name\AppData\Local\Google\Chrome\User Data\Default\Default

which is not the same as the profile that you would get if you opened chrome under that user profile normally.

You can also verify your settings if you open a command prompt, navigate to the chrome executable directory, and run chrome with the options specified similar to this:

chrome.exe --user-data-dir="C:\Users\user_name\AppData\Local\Google\Chrome\User Data"

Finally, you can go to a new tab in Chrome and browse to chrome://version/ you will see the actual profile that is being used. It will be listed like:

Profile Path C:\Users\user_name\AppData\Local\Google\Chrome\User Data\Default


These combinations did trick for me :)

System.setProperty("webdriver.chrome.driver","C:\\chromedriver.exe");ChromeOptions options = new ChromeOptions();options.addArguments("user-data-dir=C:/Users/user_name/AppData/Local/Google/Chrome/User Data");options.addArguments("--start-maximized");driver = new ChromeDriver(options);


Path where Chrome stores the profiles on Linux.

String chromeProfilePath = "/home/(user)/.config/google-chrome/Profile3/";

Creating ChromeOptions object, desabling the extensions and adding the profile I want to use by ".addArguments".

ChromeOptions chromeProfile = new ChromeOptions();chromeProfile.addArguments("chrome.switches", "--disable-extensions");chromeProfile.addArguments("user-data-dir=" + chromeProfilePath);

As said above by JasonG, after this point Google-Chrome will append \Default to the String you've provided.

There is a "/Default" folder inside "/Profile3" directory, so what I did was...

I copied the content of "/Profile3" to the "/Default" folder.

Set the Browser System Properties and Path as you usually do, call the constructor that receives a ChromeOption and it will work fine.

WebDriver driver = new ChromeDriver(chromeProfile);