2

Step:1

WebDriver wd = new FirefoxDriver();
//Removed this code after stackoverflow suggestion in comments
//wd.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
wd.manage().timeouts().pageLoadTimeout(5, TimeUnit.SECONDS);
wd.get("http:\\some url");

Step:2

(new WebDriverWait(wd, 5)).until(ExpectedConditions.
                presenceOfElementLocated(By.name("some name")));

Step:3

Some code going on......

I debug the above code, and the step 2 reached. But the step 3 is not reached after the given time out 5 seconds in any case. It is getting blocked until the page loaded fully.

The By.name("some name") is in the start of the page source.

But if i stop the browser manually from loading with in 15 seconds, then the step 3 is getting reached. So how the timeout 5 seconds is getting used here. And is there any way to reach step 3 with out manual stop or before the page load fully.?

I am using selenium 2.46.0 library and firefox 28. And also checked with firefox version 35,36 & 37

The url takes at least 4 minutes to load fully in the internet connection which i am using

Please let me know if any additional details needed.

Thanks in advance.

Jeet
  • 1,006
  • 1
  • 14
  • 25
  • Please update your firefox to latest and remove `wd.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);` as you're already using webdriverwait – Madhan Jul 04 '15 at 14:54
  • I tried with firefox 38.0.5 but there are some [Compatibility issue](http://stackoverflow.com/questions/30473556/firefox-is-crash-when-start-by-selenium-firefox-driver) made application to not run. So using version 28. Let me check by removing the code – Jeet Jul 04 '15 at 16:17
  • Use 38 or 37 then You can download that from [here](http://ftp.mozilla.org/pub/mozilla.org/firefox/releases/) – Madhan Jul 04 '15 at 16:57
  • Just now checked with firefox version 35 and 36. Still the same behavior. – Jeet Jul 04 '15 at 17:17

1 Answers1

0

@Jeet - I have gone through same issue. Work around I'm sharing which really works for me

Working Solution :

static void waitForPageLoad(WebDriver wdriver) {
    WebDriverWait wait = new WebDriverWait(wdriver, 60);

    Predicate<WebDriver> pageLoaded = new Predicate<WebDriver>() {

        @Override
        public boolean apply(WebDriver input) {
            return ((JavascriptExecutor) input).executeScript("return document.readyState").equals("complete");
        }

    };
    wait.until(pageLoaded);
}