1

I have been struggling with Selenium and ChromeDriver now for a while and I can't seem to get it to work. My tests worked fine until last week, when I started to get the error of ChromeDriver not being able to start. I only get the error like one third of the time when I am running my scripts, and most often when I am running several scripts after each other.

Versions I use:

  • Java 12.0.1
  • Selenium: 3.141.59
  • Google Chrome: 76.0.3809.87
  • ChromeDriver: 76.0.3809.68
  • Windows 10

This is the error I get:

org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:48'
System info: host: 'host', ip: '172.20.10.2', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '12.0.1'
Driver info: driver.version: ChromeDriver
    at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:202)
    at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:188)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:79)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:213)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:181)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:168)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:157)
    at com.salesforce.BaseTest.setUp(BaseTest.java:40)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:567)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)
    at org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:59)
    at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:458)
    at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:222)
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:523)
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:719)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:989)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
    at org.testng.TestRunner.privateRun(TestRunner.java:648)
    at org.testng.TestRunner.run(TestRunner.java:505)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:455)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:450)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:415)
    at org.testng.SuiteRunner.run(SuiteRunner.java:364)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:84)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1208)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1137)
    at org.testng.TestNG.runSuites(TestNG.java:1049)
    at org.testng.TestNG.run(TestNG.java:1017)
    at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:10488/status] to be available after 20002 ms
    at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:100)
    at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:197)
    ... 37 more
Caused by: java.util.concurrent.TimeoutException
    at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:204)
    at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:156)
    at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:75)
    ... 38 more

Following code snippet is part of my base class where the error occur. The error always occur when a new instance of the ChromeDriver is created. The base test class is called every time a new test is created:

@BeforeMethod
protected void setUp() throws MalformedURLException {
    System.setProperty("webdriver.chrome.driver",
        "-my path to chromedriver-\\chromedriver.exe");

    ChromeOptions capability = new ChromeOptions();
    capability.addArguments("--no-sandbox");

    driver = new ChromeDriver(capability);
    wd = new WebDriverWait(driver, WD_TIMEOUT);
}

@AfterMethod(alwaysRun = true)
protected void tearDown() {
    driver.quit();  
}


What I have already tried:

  • Re install Google Chrome (according to instructions here) and make sure a ChromeDriver that is recommended for the correct Google Chrome version is used.
  • Use updated versions of Selenium, Google Chrome and ChromeDriver
  • Launch the same Chrome binary that my test uses from command prompt. On http://localhost:9515/status I can see the message "ChromeDriver ready for new sessions." so it works fine to start the chromedriver.exe.
  • Tried with the --no-sandbox option
  • Made sure the ChromeDriver quits after each session by calling the AfterMethod with always run true flag.

As mentioned in the beginning, my scrips runs fine for some scripts, but sometimes Chrome is not able to start. It is not always the same test script that creates the error, it varies. Anyone have any idea for how to solve this problem?

Krishnan Mahadevan
  • 14,121
  • 6
  • 34
  • 66
supersoffi
  • 21
  • 6
  • Update the question with the complete text based trace logs for further analysis. – undetected Selenium Aug 05 '19 at 12:10
  • @DebanjanB Thank you for answer! I have added the complete trace logs now – supersoffi Aug 05 '19 at 12:21
  • Does this [discussion](https://stackoverflow.com/questions/54876955/unable-to-import-org-openqa-selenium-webdriver-using-selenium-and-java-11/54880228#54880228) helps you? – undetected Selenium Aug 05 '19 at 12:23
  • @DebanjanB No, or since I don't get any errors in my code and the tests sometimes run correctly I don't think the Java version is the problem – supersoffi Aug 05 '19 at 13:12
  • After 20 seconds times out for http://localhost:10488/status from logs. Do you have chromedriver service process running in background.? Check in task manager – Rahul L Aug 05 '19 at 16:36
  • Please update to jdk1.8.0_191 and try, this problem happens when there is a mismatch between selenium and jdk versions . – mk_ Aug 05 '19 at 19:35
  • I have a feeling this is a timing issue, where ChromeDriver is trying to start Chrome while another instance is still closing down/cleaning up. (maybe due to creating/cleaning up temporary dirs/profiles for use during testing...) – pcalkins Aug 05 '19 at 22:34
  • did you get a "session not created" error somewhere down the line? – pcalkins Aug 05 '19 at 23:05
  • @mk_ change the version to jdk1.8.0_191 did not work, I got the same error message – supersoffi Aug 06 '19 at 07:18
  • @RahulL Yes, there are some chromedriver.exe processes left running in the task manager. When I manually quit them in task manager before running just one test, it still not work – supersoffi Aug 06 '19 at 07:20
  • @pcalkins Yes, I believe so too. I can't find any "session not created" message anywhere though. – supersoffi Aug 06 '19 at 07:22
  • https://github.com/SeleniumHQ/selenium/blob/master/java/client/src/org/openqa/selenium/remote/service/DriverService.java#L198 20 Second is hard coded .Unfortunately you may not be able to change it and give more time for chromedriver server to start – Rahul L Aug 06 '19 at 07:36
  • @RahulL yeah. But since it starts within ~2 seconds those times the tests work I don't think the chromedriver need more time to start, or? – supersoffi Aug 06 '19 at 07:53

1 Answers1

1

The problem is now solved when I changed some versions of the software I used. Following steps solved the problem:

  • Usage of JDK 1.8.0_221 instead of Java 12
  • Usage of Google Chrome version 76.0.3809.87
  • Usage of ChromeDriver version 76.0.3809.68
  • After changing to all these versions, I rebooted the system and my tests finally worked again.
supersoffi
  • 21
  • 6
  • How can _Usage of JDK 1.8.0_221 instead of Java 12_ solve your issue, you have already replied to me _since I don't get any errors in my code and the tests sometimes run correctly I don't think the Java version is the problem_ – undetected Selenium Aug 06 '19 at 14:49
  • @DebanjanB Actually I have no idea why it finally worked, since I had tried to change to other versions of Java before and it didn't work I didn't thought it would work to change it either. I guess the Selenium version I use combined with the chromedriver only works with java 8u211 and not java 12.0.1 which I used before – supersoffi Aug 08 '19 at 08:44
  • I have explained it all in the dup marked discussion. Glad to know your issue got resolved. Upvoted. – undetected Selenium Aug 08 '19 at 09:01