Galileo123
Galileo123

Reputation: 195

ChromeDriver crashes and does not create a session when chrome is already open in selenium-jvm

There are two parts of this problem -

  1. When a chrome browser is already open and I trigger my selenium-java test case to run against the chrome it doesn't open a new chrome session.
  2. It uses the existing chrome which is open and starts opening new tabs but still doesn't work.

My driver initialization looks like as below :

System.setProperty("webdriver.chrome.driver", ConfigUtils.getCurrentDirectory()+ Chromefile.getPath());               
ChromeOptions options = new ChromeOptions();
//options.addArguments("--headless");
options.addArguments("--no-sandbox");
options.addArguments("start-maximized");
options.addArguments("disable-infobars");
options.addArguments("disable-extensions");
options.setExperimentalOption("useAutomationExtension", false)
driver = new ChromeDriver(options);

I have tried couple of things suggested on Stack Overflow -

  1. Someone described that this is a problem because chromedriver cannot spin up another instance of chrome - default profile. So I have added the following line in the above code -

    String profile1 = "C:\\Users\\user_id\\Documents\\ChromeProfile1\\";
    options.addArguments("user-data-dir="+profile1);
    

This was done so that chromedriver could launch a new profile of chrome. And it does open a new chrome window but didn't navigated to the URL.

As per the official documentation of chromedriver -

By default, ChromeDriver will create a new temporary profile for each session.

And I never has to do this before. I am not sure why this is not working and what else can I do?

I am using -

Selenium-java version 3.141.1
ChromeDriver version 2.38
Chrome version 70
Windows 10

Please note- The chrome and chromedriver version I have mentioned above are compatible and working fine when chrome is not already running Also, I can run the same test in headless mode while chrome window is already open.

let me know if you need anymore info. Error I am getting is as below-

Starting ChromeDriver 2.38.552522 (437e6fbedfa8762dec75e2c5b3ddb86763dc9dcb) on port 18020 Only local connections are allowed. org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: crashed (Driver info: chromedriver=2.38.552522 (437e6fbedfa8762dec75e2c5b3ddb86763dc9dcb),platform=Windows NT 10.0.17134 x86_64) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 61.87 seconds Build info: version: '3.141.5', revision: 'd54ebd709a', time: '2018-11-06T11:42:16' System info: host: 'XXXX', ip: 'XXXX', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_162' Driver info: driver.version: ChromeDriver

Upvotes: 1

Views: 2561

Answers (1)

John Chen
John Chen

Reputation: 61

ChromeDriver 2.38 only supports Chrome 65 through 67. Please see the release notes at https://chromedriver.storage.googleapis.com/2.38/notes.txt. It may happen to work with some other versions of Chrome under certain conditions, but such usage is unsupported. It is recommended to use ChromeDriver 2.44 with Chrome 70.

I don't see any problems with the code you posted. Hopefully you'll be able to get better results after downloading a newer ChromeDriver.

Upvotes: 2

Related Questions