問題描述
如果我的問題聽起來很重要,我提前道歉,我是 QA 和 Selenium 的新手.
My apologies in advance if my question sounds primary, I am very new at QA and Selenium.
兩者之間的確切區(qū)別是什么:
What is the exact difference between:
wait.until(ExpectedConditions.visibilityOfElementLocated
(By.xpath("http://a[text()='Show advanced settings...']"))).click();
和
wait.until(ExpectedConditions.presenceOfElementLocated
(By.xpath("http://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-
可見性公共靜態(tài) ExpectedCondition visibilityOf(WebElement 元素)期望檢查已知存在于頁面 DOM 上的元素是否可見.可見性是指元素不僅顯示出來,而且高度和寬度都大于0.參數(shù):
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:
這篇關(guān)于“ExpectedConditions.visibilityOfElementLocated"之間的確切區(qū)別是什么?和“ExpectedConditions.presenceOfElementLocated"的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!