Reputation: 51
I am using both wait(until.elementLocated(element, timeout))
and wait(until.elementVisible(element, timeout))
. The 'wait until visible' one is failing in places where 'wait until located' does not. Why?
Upvotes: 5
Views: 6157
Reputation: 193108
As your question is the difference between wait(until.elementLocated(element, timeout))
and wait(until.elementVisible(element, timeout))
and you haven't tagged any Selenium binding, I will explain it from a Java perspective.
until.elementLocated()
is equivalent to presenceOfElementLocated()
in Java. It checks that an element is present within the HTML DOM of a page. This does not necessarily mean that the element is visible. So there's no guarantee that it's interactable.until.elementVisible()
is equivalent to visibilityOfElementLocated()
in Java. It checks that an element is present within the HTML DOM of a page and is visible. Visibility means that the element is not only displayed but also has a height and width that is greater than 0. Again this does not necessarily mean that the element is interactable, i.e. clickable.For more details on ExpectedConditions
in Java, see the docs.
Upvotes: 3
Reputation: 364
Both until.elementLocated(element, timeout) and until.elementVisible(element, timeout) are used to get the element.
But I would guess that elementLocated will be faster because it's just check that an element is present on the DOM of a page and not necessarily mean that the element is visible. while the elementVisible has to check that an element is present on the DOM of a page and visible. Visibility means that the element is not only displayed but also has a height and width.
Hope this will explain the difference.
Upvotes: 1
Reputation: 2563
Wait until visible does exactly that. It waits until the element is visible. An element can be in the DOM but be hidden. In that case, it would be able to be located but not visible.
Upvotes: 1