开发者

waitForCondition is not working but Thread.sleep makes the script work

When I apply Thread.sleep(2000) application works well but on waitForCondition it fails. Is there any better way to use waitForCondition function? Please provide some examples. Can we give //h1[@class='some'] in waitForCondition? or waitForCondition works on specific way?

I have used as:

selenium.waitForCondition("selenium.isElementPresent(\"//div[@id='pagging-section']\")","5000");

But that fails. Thread.sleep works well, but I have been advised not to use this method.

Please share with me the proper use of waitF开发者_JAVA百科orCondition and any other better way to wait and find the element and proceed.


There can be a lag between when selenium thinks the page has loaded and it actually loads. Basically, I had the same problem.

I wrote my own little framework to handle this situation: While checking for conditions, I had a loop with Thread.sleep(200) that caught any "not found" exceptions and gave up after a timeout (I used 20 seconds) and it works great.

Use Thread.sleep()

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜