Use custom Chrome profile with Selenium WebDriver

Hi,

Today, I was struggling with webdriver and Chrome.
As I found out, currently there’s no built-in webdriver feature that allows start Chrome with custom profile.
Fortunetely I found short work-around 🙂

There’re only 2 steps to follow:
#1: Create custom Chrome profile
#2: Add chrome.switches to Chrome driver capabilities

Steps:
#1: To create new custom Chrome profile follow these instructions:
http://www.labnol.org/software/create-family-profiles-in-google-chrome/4394/

#2: Then add new capability to your

//....

capabilities = DesiredCapabilities.chrome();
String[] switches = {"user-data-dir=\\path\\to\\your\\custom\\chrome\\profile\\directory"};
capabilities.setCapability("chrome.switches", switches);
webDriver = new RemoteWebDriver(gridServerURL, capabilities);

//....

Hope you’ll find this useful 🙂

Cheers,
J