Friday, 8 March 2013

Load Default/Custom Chrome Profile to run tests using Selenium WebDriver

1. Download Chromedriver 2.4
2. Extract the zipped folder and locate .exe file to C:/ folder

ChromeOptions options = new ChromeOptions();
options.addArguments("user-data-dir=C:/Users/user_name/AppData/Local/Google/Chrome/User Data");
driver = new ChromeDriver(options);

If you face such error:
"org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited normally"

Then try to create a new Chrome profile and execute tests.

1| Copy the folder, 'User Data' and paste it on the same folder with different name. e.g., New User
2| Open the folder, 'New User'.
3| Rename the folder, 'Default';  so that after your test run, a new folder named, 'Default' will be created.
4| Now, replace the directory on your code with C:/Users/user_name/AppData/Local/Google/Chrome/New User
5| If you like to test the profile, then bookmark some of the sites & observe them on next run.

IE doesn't need profile setup to run tests because they run on Server user while Firefox and Chrome works with binary.


  1. HI Admin,
    I tried the above code but only the normal browser is openning, i could not able to open sepecific profile browser using this code can u please help me.


  2. Sakthy, thanks for letting me know this; I have changed the deprecated Chromedriver link; Also updated the code. Please let me know on any issues.


  3. Hi Sam,
    First of all thanks for sharing the knowledge...:)
    I tried this and it worked for me when there were no other chrome instance present in the system, it launched a fresh browser window and loaded the URL...fine

    But when there is a chrome window already present , the code opens another tab and then it seems not working and throwing "org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited normally"...

    Also do you have any idea what arguments we need to pass to change the chrome profile in a such a way that it will ask the user 'where to save the file window dialogue when downloading it' ... we can change this manually from the chrome settings .... but that looks not persisting in the browser opened by chrome driver....

  4. Hi Musaffir,
    I am also experiencing the same issue . Please tell me how it worked for you

  5. On what server running IE?

  6. The problem i am facing it did open the chrome browser but URL is not loading.

    1. Even for me chrome browser is launched but the URL is not loading. Are you still facing this issue? If not please let me know the solution.

  7. Thanks for the great information in your blog Selenium Training in Chennai

  8. How to set preferences for Chrome? Pls help.

  9. Is there any way to reload the same chrome profile for each test??

  10. Thank you Prashanth S, it is really working, if you all are trying to load profile for Cookies with/before above Prashanth code. Take a copy of Default\Cookies file and paste/replace it before Loading Driver. After loading Driver if you want specific cookies then you can use addcookie to add specific cookies(For More info Refer Guru99 site- Retriving adding cookies at runtime).