开发者

Selenium WaitForCondition fails after 30 minutes instead of 20 seconds

In our functional tests we use ISelenium.WaitForCondition method to test whether AJAX calls are finished using something like this:

_selenium.WaitForCondition("!selenium.isElementPresent(\"" + locator + "\")", "20000");

Sometimes this code fails with SeleniumException:

Selenium.SeleniumException: ERROR: Com开发者_高级运维mand timed out

But instead 20000 ms it takes 30 minutes to fail and after that all subsequent selenium calls fail with something like:

SeleniumException : ERROR Server Exception: unexpected command
json={command:"waitForCondition",target:"!selenium.isElementPresent(\"//div[contains(@id, \'atlProgress\') and contains(@style, \'display: block\')]\")",value:"20000"}
in place before new command waitForCondition could be added

We use .NET Selenium port: ThoughtWorks.Selenium.Core, Version=2.7.0.0 and not a WebDriver.

What could we do to avoid these errors?


Selenium uses (at least) two timeouts:

  • one is for various 'wait' commands and is send to browser for javascript to wait - you can send it in some calls exactly as you do in 'waitForCondition';

  • another one is server timeout, which can be set when starting the server, that governs how long Selenium server will wait for response from the browser before it will return 'Command timed out' error.

I believe the problem you are facing is that you send a command to wait for 20 seconds, but your server never gets a response from the browser and waits for it for 30 minutes. I reckon you have set the server timeout to 30 minutes somewhere.

The lack of response may be caused by crashed or hanged browser, which in turn leads to 'Unexpected command' error. I describe this case in a bit more detail in this answer.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜