问题
My apologies in advance if my question sounds primary, I am very new at QA and Selenium.
What is the exact difference between:
wait.until(ExpectedConditions.visibilityOfElementLocated
(By.xpath("//a[text()='Show advanced settings...']"))).click();
and
wait.until(ExpectedConditions.presenceOfElementLocated
(By.xpath("//a[text()='Show advanced settings...']"))).click();
I had a look at here but did not figure it out.
回答1:
The visibilityOfElmementLocated checks to see if the element is present and also visible. To check visibility it makes sure the element has a height and width greater than 0.
The presenceOfElementLocated just checks the dom to see if it can locate an element no matter its visibility.
Source: https://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/support/ui/ExpectedConditions.html#visibilityOf-org.openqa.selenium.WebElement-
visibilityOf public static ExpectedCondition visibilityOf(WebElement element) An expectation for checking that an element, known to be present on the DOM of a page, is visible. Visibility means that the element is not only displayed but also has a height and width that is greater than 0. Parameters:
来源:https://stackoverflow.com/questions/33242882/what-is-the-exact-difference-between-expectedconditions-visibilityofelementloca