本文介绍了“ExpectedConditions.visibilityOfElementLocated”与“ExpectedConditions.visibilityOfElementLocated”之间的确切区别是什么?和“ExpectedConditions.presenceOfElementLocated”和“ExpectedConditions.presenceOfElementLocated”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我的问题听起来很重要,我提前道歉,我在QA和Selenium非常新。

My apologies in advance if my question sounds primary, I am very new at QA and Selenium.

之间的确切区别是:

 wait.until(ExpectedConditions.visibilityOfElementLocated
                    (By.xpath("//a[text()='Show advanced settings...']"))).click();

 wait.until(ExpectedConditions.presenceOfElementLocated
                    (By.xpath("//a[text()='Show advanced settings...']"))).click();

我看了但是没弄明白。

推荐答案

visibilityOfElmementLocated检查元素是否存在且是否可见。要检查可见性,请确保元素的高度和宽度大于0.

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.

presenceOfElementLocated只检查dom以查看它是否可以定位元素,无论其可见性如何。

The presenceOfElementLocated just checks the dom to see if it can locate an element no matter its visibility.

资料来源:

visibilityOf
public static ExpectedCondition visibilityOf(WebElement element)
An期望检查已知存在于页面的DOM上的元素是否可见。 可见性意味着该元素不仅会显示,而且其高度和宽度也会大于0.
参数:

visibilityOfpublic 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:

这篇关于“ExpectedConditions.visibilityOfElementLocated”与“ExpectedConditions.visibilityOfElementLocated”之间的确切区别是什么?和“ExpectedConditions.presenceOfElementLocated”和“ExpectedConditions.presenceOfElementLocated”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-11 22:20