presenceOfElementLocated()
presenceOfElementLocated() is the expectation for checking that an element is present on the DOM of a page. It is defines as:
public static ExpectedCondition<WebElement> presenceOfElementLocated​(By locator)
An expectation for checking that an element is present on the DOM of a page. This does not necessarily mean that the element is visible.
Parameters:
locator - used to find the element
Returns:
the WebElement once it is located
So presenceOfElementLocated doesn't confirms the element is visible with in the DOM Tree. This phenomenon can be observed with WebElement having:
CSS visibility
property set as hidden
. As an example:
h2.b {
visibility: hidden;
}
style attribute is set as "display: none;"
. An example:
<select class="pretty-dropdown" id="alBrandsList" style="display: none;">
visibilityOfElementLocated()
visibilityOfElementLocated() is the expectation for checking that an element is present on the DOM of a page and visible. It is defined as:
public static ExpectedCondition<WebElement> visibilityOfElementLocated​(By locator)
An expectation for checking 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 that is greater than 0.
Parameters:
locator - used to find the element
Returns:
the WebElement once it is located and visible
visibilityOfElementLocated() with the browser minimized
Visibility/invisibility of the minimized browser is subjected to our naked eyes where as presenceOfElementLocated / visibilityOfElementLocated is subjective to Selenium.
You can find a relevant detailed discussion in How to execute tests with selenium webdriver while browser is minimized
References
You can find a couple of relevant detailed discussions on element displayedness in: