What is the exact difference between quot;ExpectedConditions.visibilityOfElementLocatedquot; and quot;ExpectedConditions.presenceOfElementLocatedquot;(“ExpectedConditions.visibilityOfElementLocated之间的确切区别是什么?和“ExpectedConditions.presenceOfElementLocated)
问题描述
如果我的问题听起来很重要,我提前道歉,我是 QA 和 Selenium 的新手.
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();
和
wait.until(ExpectedConditions.presenceOfElementLocated
(By.xpath("//a[text()='Show advanced settings...']"))).click();
我查看了 这里但没弄明白.
I had a look at here but did not figure it out.
推荐答案
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.
来源:https://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/support/ui/ExpectedConditions.html#visibilityOf-org.openqa.selenium.WebElement-
可见性公共静态 ExpectedCondition visibilityOf(WebElement 元素)期望检查已知存在于页面 DOM 上的元素是否可见.可见性是指元素不仅显示出来,而且高度和宽度都大于0.参数:
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:
这篇关于“ExpectedConditions.visibilityOfElementLocated"之间的确切区别是什么?和“ExpectedConditions.presenceOfElementLocated"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:“ExpectedConditions.visibilityOfElementLocated"之间的确切区别是什么?和“ExpectedConditions.presenceOfElementLocated"
基础教程推荐
- 降序排序:Java Map 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01