问题
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
The above implicity wait code is not working for me on Google chrome. I have tried with selenium 2.47 and 2.53.1
回答1:
You should read up on what implicit wait actually does and how it works.
http://www.seleniumhq.org/docs/04_webdriver_advanced.jsp#implicit-waits
It's not something that you call to wait for 10 seconds, it only comes into play when an element that is being searched for is not available... then the implicit wait is triggered and that element is polled up to the 10s. If the element is already there, then there is no wait time. Thread.sleep()
pauses execution no matter what but is not a good practice.
回答2:
An implicit wait is to tell WebDriver to poll the DOM for a certain amount of time when trying to find an element or elements (if) they are not immediately available. The default setting is 0. Once set, the implicit wait is set for the life of the WebDriver object instance.
来源:https://stackoverflow.com/questions/41143520/driver-manage-timeouts-implicitlywait10-timeunit-seconds-does-not-working