7
votes

In my Java project I am using Selenium for web automation. I am using chromedriver v2.20 executable. First "ChromeDriverService" is initialised and that is used to create ChromeDriver like, "new ChromeDriver(service, capabilities);". Also I used BrowserMobProxy to capture all web requests. In my test I navigate to some URLs multiple times, after each navigation driver implicitly waits for few seconds, then polls result. But while Execution it gives me timeout Exception.

In my research I came across solutions which are not working for me:

  1. Instead of implicitlyWait use Thread.sleep
  2. Replace new RemoteWebDriver(service.getUrl(), capabilities); by new ChromeDriver(service, capabilities);
  3. After new ChromeDriver(...), wait for 1 sec using Thread.sleep(1000);

Can anyone please tell me why this error occurs ? how to handle this ?

ShouldPostToServerTest.java:

@Test 
public void setTest() throws Exception {
    for (int i = 0; i < 3; i++) {
        nav();
        poll();
    }
}

private void nav() {
    String[] navTo = {"http://www.bestbuy.com","http://www.amazon.com"};
    for (int n = 0; n < 30 / navTo.length; n++) {
        for (String url : navTo) {
            chrome.navigateTo(url);
            chrome.waitFor(5000);
        }
    }
}

private void poll() {
    int pollInterval = 1000;
    int remaining = 120 * 1000;
    boolean found = false;
    while (remaining > 0) {
        if (found) // populateResult(), omitted for now.
            break;

        chrome.waitFor(pollInterval);
        remaining -= pollInterval;
    }
}

Chrome.java:

public void navigateTo(String url) {
    if (driver == null)
        return;

    driver.navigate().to(url); // TimeOut 
}
public void waitFor(long waitFor) {
    long start = System.currentTimeMillis();
    driver.manage().timeouts().implicitlyWait(waitFor, TimeUnit.MILLISECONDS);
    long duration = System.currentTimeMillis() - start;
    long remaining = waitFor - duration;
    if (remaining > 0) {
        try {
            Thread.sleep(remaining);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }
}

Error stack trace:

Connected to the target VM, address: '127.0.0.1:57086', transport: 'socket'
Starting ChromeDriver 2.20.353124 (035346203162d32c80f1dce587c8154a1efa0c3b) on port 13817
Only local connections are allowed.
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Vector smash protection is enabled.
Vector smash protection is enabled.
[723.497][SEVERE]: Timed out receiving message from renderer: 600.000
[1323.497][SEVERE]: Timed out receiving message from renderer: 600.000

Exception:

org.openqa.selenium.WebDriverException: unknown error: cannot determine loading status from timeout: Timed out receiving message from renderer: 600.000 (Session info: chrome=45.0.2454.101)
(Driver info: chromedriver=2.20.353124 (035346203162d32c80f1dce587c8154a1efa0c3b),platform=Linux 3.19.0-28-generic x86_64) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 1200.01 seconds Build info: version: '2.48.2', revision: '41bccdd10cf2c0560f637404c2d96164b67d9d67', time: '2015-10-09 13:08:06' System info: host: 'yogesh-ubuntu', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.19.0-28-generic', java.version: '1.8.0_60' Driver info: org.openqa.selenium.chrome.ChromeDriver Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, chrome={userDataDir=/tmp/.com.google.Chrome.rgDfCi}, takesHeapSnapshot=true, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=45.0.2454.101, platform=LINUX, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}] Session ID: a97aeb9a53ddd77e8edfac64019cc599 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:422) 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:647) at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:311) at org.openqa.selenium.remote.RemoteWebDriver$RemoteNavigation.to(RemoteWebDriver.java:927) at app.core.browsers.chrome.Chrome.navigateTo(Chrome.java:112) at app.core.extensions.tests.ShouldPostToServerTest.nav(ShouldPostToServerTest.java:58) at app.core.extensions.tests.ShouldPostToServerTest.setTest(ShouldPostToServerTest.java:49)

2
In my case if my window is getting closed due to some close button in application, i am running into this error. any idea how it can be solved?Varun

2 Answers

4
votes

Your code runs fine. Might be you using outdated chrome driver. I suggest to use latest exe of chrome driver.

0
votes

This error message...

Connected to the target VM, address: '127.0.0.1:57086', transport: 'socket'
Starting ChromeDriver 2.20.353124 (035346203162d32c80f1dce587c8154a1efa0c3b) on port 13817
.
org.openqa.selenium.WebDriverException: unknown error: cannot
determine loading status from timeout: Timed out receiving message
from renderer: 600.000   (Session info: chrome=45.0.2454.101)  
(Driver info: chromedriver=2.20.353124
(035346203162d32c80f1dce587c8154a1efa0c3b),platform=Linux 3.19.0-28-generic x86_64) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 1200.01 seconds
Build info: version: '2.48.2', revision: '41bccdd10cf2c0560f637404c2d96164b67d9d67', time: '2015-10-09 13:08:06' System info: host: 'yogesh-ubuntu', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.19.0-28-generic', java.version: '1.8.0_60' Driver info: org.openqa.selenium.chrome.ChromeDriver

...implies that the ChromeDriver was unable to initiate/spawn a new Browsing Context i.e. Chrome Browser session.

Your main issue is the incompatibility between the version of the binaries you are using as follows:

  • Though your chromedriver=2.20 and chrome=45.0 are compatable.
  • But your JDK version is 1.8.0_60 which is pretty ancient.

So there is a clear mismatch between JDK v8u60 , Selenium Client v'2.48.2 , ChromeDriver v2.20 and the Chrome Browser v45.0


Solution

Ensure that:

  • JDK is upgraded to current levels JDK 8u241.
  • Selenium is upgraded to current levels Version 3.141.59.
  • ChromeDriver is updated to current ChromeDriver v80.0 level.
  • Chrome is updated to current Chrome Version 80.0 level. (as per ChromeDriver v80.0 release notes)
  • Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
  • If your base Web Client version is too old, then uninstall it through and install a recent GA and released version of Web Client.
  • Take a System Reboot.
  • Execute your @Test as non-root user.
  • Always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.