Java – waitforcondition does not work, but thread Sleep makes the script work

When I apply thread The sleep (2000) application works well, but it fails in waitforcondition Is there a better way to use the waitforcondition function? Please provide some examples Can we give / / H1 [@ class = 'some'] in waitforcondition? Or waitforcondition works in a specific way?

I used:

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

But that failed Thread. Sleep works well, but I am advised not to use this method

Please share with me the correct use of waitforcondition and any other better way to wait and find elements and continue

Solution

When selenium thinks the page is loaded and actually loads, there may be a delay Basically, I have the same problem

I wrote my own little framework to deal with this situation: when checking conditions, I have a circular thread Sleep (200) catches any "not found" exception and discards it after timeout (I used it for 20 seconds) and it is valid

Use thread sleep()

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>