Ankit Rustagi
Ankit Rustagi

Reputation: 5637

Unable to start Chrome browser with user profile in Selenium

I am trying to open a Chrome browser window with an existing user profile.

    String dir= "/Users/labuser/Library/Application Support/Google/Chrome";        
    ChromeOptions options = new ChromeOptions();
    options.addArguments("--user-data-dir="+dir);
    driver = new ChromeDriver(options); // throws an exception!

I confirmed the user directory path by looking at chrome://version page. (screenshot below)

enter image description here

Due to some reason, this code throws an exception with very less information

org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited abnormally
  (Driver info: chromedriver=2.33.506106 (8a06c39c4582fbfbab6966dbb1c38a9173bfb1a2),platform=Mac OS X 10.12.6 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 60.33 seconds
Build info: version: '2.53.0', revision: '35ae25b', time: '2016-03-15 17:00:58'
System info: host: 'arustagi-wx-3', ip: '10.41.25.35', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.6', java.version: '1.8.0_111'
Driver info: org.openqa.selenium.chrome.ChromeDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:249)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:144)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:170)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:159)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:148)

Edit

I am using the following chrome browser, this falls in the supported range of browsers

Version 61.0.3163.100

Upvotes: 0

Views: 2421

Answers (2)

Ankit Rustagi
Ankit Rustagi

Reputation: 5637

Finally got this fixed. I was working on macOS and found out that i needed to quit the browser cleanly.

After closing the browser window, i had to right click on the icon in the dock and press quit. The selenium script would work perfectly fine after this.

Upvotes: 1

Davide Patti
Davide Patti

Reputation: 3461

You are using the latest version of the ChromeDriver

chromedriver=2.33.506106

with Selenium 2.53. You should use the latest release.

Anyway, what is your browser version? Here you can take a look which are the browsers version supported (based on your chromedriver).

EDIT

I tried with:

  • Selenium 3.5.3
  • ChromeDriver v2.33
  • Google Chrome Version 62.0.3202.62 (Official Build) (64-bit)

From chrome://version/, my profile path is

/Volumes/MacintoshSSD/Users/DurdenP/Library/Application Support/Google/Chrome/Default 

Trying

    String chromeDriver ="pathTo/ChromeDriver/chromedriver";
    System.setProperty("webdriver.chrome.driver", chromeDriver);
    ChromeOptions options = new ChromeOptions();
    String dir= "/Volumes/MacintoshSSD/Users/DurdenP/Library/Application Support/Google/Chrome";
    options.addArguments("user-data-dir="+dir);
    ChromeDriver driver = new ChromeDriver(options);

it works.

Upvotes: 1

Related Questions