20

When I create a new chrome driver in Selenium while Google Chrome is already running AND I am referencing the users settings/data (via user-data-dir). A new Chrome window will open, but my application will hang. The ChromeDriver console will display the following error each second: DevTools Request: 127.0.0.1:12585/json/version. DevTools request failed

Screenshot: enter image description here

Code to instantiate the driver:

        ChromeDriverService driverService = ChromeDriverService.CreateDefaultService();
        //driverService.HideCommandPromptWindow = true;
        driverService.EnableVerboseLogging = true;

        string path = Environment.ExpandEnvironmentVariables("%LOCALAPPDATA%\\Google\\Chrome\\User Data");

        ChromeOptions options = new ChromeOptions();
        options.AddArguments("user-data-dir=" + path);
        options.AddArguments("--start-maximized");
        options.AddArguments("--disable-extensions");

        IWebDriver driver = new ChromeDriver(driverService, options);

This will work perfectly fine in every instance if I do not try and load user settings/data. If I am trying to load user setting/data it will only work if there is no instance of Chrome running on the device already.

Versions:

  • Selenium v 2.47.0
  • ChromeDriver v 2.16.333243
  • Chrome v44.0.2403

What can I do to resolve this?

Douglas Gaskell
  • 9,017
  • 9
  • 71
  • 128
  • For any one stumbling on this issue, pls refer the [github page](https://github.com/seleniumhq/selenium/issues/886) – karthickj25 Mar 28 '18 at 06:53
  • Just filled an issue here on this - https://bugs.chromium.org/p/chromedriver/issues/detail?id=2443 - has anyone solved/got around this?! – r0bb077 May 31 '18 at 02:43

1 Answers1

2

If anyone was looking for answer like me;

https://bugs.chromium.org/p/chromedriver/issues/detail?id=2443

This behavior is by design. Two instances of Chrome can't use the same user-data-dir at the same time. Otherwise they would try to update the same set of files and cause corruptions. So if an instance is already running, attempting to start another instance using the same user-data-dir will cause the second instance to ask the first instance to open a new window, and then the second instance exits.

r0bb077
  • 732
  • 2
  • 11
  • 33