Waitforelementvisible method can wait less than 1 second?

Hi all,

Does anybody know if waitforelementvisible() method can wait less than 1 second? I am
on the situation that I need for waiting for some elements to appear and then get data from those elements if the exists or are visible, otherwise…to continue the script
and the test continues the flow without failing like catching the error and continue.
Do you know wich is the better and fast way to to that?


The wait methods can, and will, wait for less than one second, assuming the condition is met in less than one second. The integer value that you pass to those methods is simply a timeout, in other words, the maximum time it will wait before moving on.

@Brandon_Hein thanks for your reply but how i cant wait less than 1 second to wait for an element ?

That’s what I’m telling you. The waitForElementVisible() method DOES wait for less than one second, assuming the element becomes visible in less than a second.

@Brandon_Hein im sorry . I want to wait less time than 1 second if the element is not visible and continue the script with another actions, so the question is how to achieve that, maybe is there another posibility with another method. I need to retrieve thousand of elemnts information so if the element is not visible in 1 second, im waiting to much time (1 second) for each element of the page and multiplied by more than thousand pages. Thats why the question. Thanks!

Ok so you want your timeout to be < 1 second. That’s a different story.

To do that, you’ll need to implement your own WebDriverWait:

WebDriver driver = DriverFactory.getWebDriver()
WebElement elementToWaitFor = WebUiCommonHelper.findWebElement(findTestObject("path/to/my/test/object"))
new WebDriverWait(driver, 0.5).until(ExpectedConditions.visibilityOf(elementToWaitFor))

In the above code, the timeout is 0.5 seconds, or 500 ms. With WebDriverWait, you can also change the polling rate, like this:

new WebDriverWait(driver, 0.5, 30).until(ExpectedConditions.visibilityOf(elementToWaitFor))

which means it will check every 30 ms, up to 500 ms.

1 Like