vbail
vbail

Reputation: 364

Firefox WebDriver hangs waiting for page to load

sometimes in my test done with Selenium 2.41 and tested with Firefox 28 the execution hangs waiting for page to load.

This is the wait condition:

int time = 30;    
WebDriverWait wait = new WebDriverWait(webDriver, time);
ExpectedCondition<Boolean> pageLoadCondition = new ExpectedCondition<Boolean>() {
   public Boolean apply(WebDriver driver) {
      return ((JavascriptExecutor)driver).executeScript("return document.readyState").equals("complete");
    }
};
wait.until(pageLoadCondition);

It's supposed that after 30 seconds this method will throw a TimeoutException, but it's not, sometimes hangs forever. This is the stacktrace produced in these situations:

java.lang.Thread.State: RUNNABLE at java.net.SocketInputStream.socketRead0(Native Method) at java.net.SocketInputStream.read(Unknown Source) at org.apache.http.impl.io.AbstractSessionInputBuffer.fillBuffer(AbstractSessionInputBuffer.java:160) at org.apache.http.impl.io.SocketInputBuffer.fillBuffer(SocketInputBuffer.java:84) at org.apache.http.impl.io.AbstractSessionInputBuffer.readLine(AbstractSessionInputBuffer.java:273) at org.apache.http.impl.conn.LoggingSessionInputBuffer.readLine(LoggingSessionInputBuffer.java:116) at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:140) at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:57) at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:260) at org.apache.http.impl.AbstractHttpClientConnection.receiveResponseHeader(AbstractHttpClientConnection.java:283) at org.apache.http.impl.conn.DefaultClientConnection.receiveResponseHeader(DefaultClientConnection.java:251) at org.apache.http.impl.conn.AbstractClientConnAdapter.receiveResponseHeader(AbstractClientConnAdapter.java:223) at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:271) at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:123) at org.apache.http.impl.client.DefaultRequestDirector.tryExecute(DefaultRequestDirector.java:682) at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:486) at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:863) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:72) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:57) at org.openqa.selenium.remote.HttpCommandExecutor.fallBackExecute(HttpCommandExecutor.java:322) at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:301) at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.execute(NewProfileExtensionConnection.java:165) at org.openqa.selenium.firefox.FirefoxDriver$LazyCommandExecutor.execute(FirefoxDriver.java:362) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:568) at org.openqa.selenium.remote.RemoteWebDriver.executeScript(RemoteWebDriver.java:504) at es.tao.commonservices.selenium.tests.TAORobotWebDriver$1.apply(TAORobotWebDriver.java:6227) at es.tao.commonservices.selenium.tests.TAORobotWebDriver$1.apply(TAORobotWebDriver.java:1) at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:208) at es.tao.commonservices.selenium.tests.TAORobotWebDriver.waitToLoad(TAORobotWebDriver.java:6230) at es.tao.commonservices.selenium.tests.TAORobotWebDriver.handleWaitToLoad(TAORobotWebDriver.java:6110)

I have set this preference for firefox profile, but it's still not working:

ffProfile = new FirefoxProfile();
ffProfile.setPreference("webdriver.load.strategy", "unstable");

Also have this properties set:

webDriver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS);
webDriver.manage().timeouts().setScriptTimeout(30, TimeUnit.SECONDS);

Upvotes: 10

Views: 7833

Answers (2)

user1050755
user1050755

Reputation: 11691

Found an unresolved bug: https://code.google.com/p/selenium/issues/detail?id=6955 - if you can, please provide a test case, primarily a reduced host page with minimal scripts where the problem still occurs so it can be repeated reliably and traced down.

Sometimes I question myself if Google uses their own tools at all.... they should have run into that bug ages ago considering how huge that company is.

Upvotes: 0

coolercargo
coolercargo

Reputation: 247

You may want to try Firefox 27.01. I upgraded to Firefox 28.0 and it seemed to break some tests I was doing using watir-webdriver. I went back to 27.01 and the tests ran again(if you go back download the whole install package as the setup only, does not seem to let you turn off auto-update so it updates itself to 28.0).

The fails were using hover and find_element.

Upvotes: 1

Related Questions