5

I am facing a strange issue with Selenium RC. I have a test which runs perfectly fine when I run my selenium server manually on the default port. The test passes in seconds. However since my tests are to run on a remote machine under hudson, I run my selenium server in background as a windows service via a utility called as nssm.

When I run the same test via my server running in background, it fails with timeout. The test should not take much time to run. Here is the test I wrote

_selenium.Click("http://www.myurl.com/mypage.aspx");
_selenium.Type("Locator", "Value");
_selenium.Click("SaveLink");
_selenium.WaitForPageToLoad("30000");

3 Answers 3

2

Try increasing pageLoad, that is -

 _selenium.WaitForPageToLoad("60000");

b/w I suggest you to not hard code wait period and read it from a method, so you could modify it in one place and have it reflected in all instances.

4
  • Increasing the time for WaitForPageToLoad will not have an impact till I increase the SetTimeout limit from 30000. However thanks for your suggestion. My issue was something different. When the page to test was rendered while testing, it was by default setting one of my select control to default value. Where-as when the server was running in background, it did not set the default value. I manually set the default value and test works fine.
    – Ashish
    Commented Jun 2, 2011 at 4:06
  • Well I did not see any instance of open method in your code snippet and the only instance available is waitForpageToLoad. As far as I know, setTimeOut is used only after using open method
    – Tarun
    Commented Jun 2, 2011 at 4:50
  • OOPS. Typo. _selenium.Click() should have been read as _selenium.Open(). Apologies.
    – Ashish
    Commented Jun 2, 2011 at 5:31
  • You may also like to consider post your answer as "Answer" and mark it right
    – Tarun
    Commented Jun 2, 2011 at 6:44
2

The issue is actually resolved. When running my test via server by opening the normal browser window, one of my required select drop-down was populated automatically. Where-as when I was trying to run my test via server running in background, the drop-down was not taking default value. I manually set the drop-down value and my tests were passing.

0

@Ashish - I have gone through issue. Sometimes,

selenium.WaitForPageToLoad("30000");

failed. 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);
}

Try It !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.