在Selenium框架中,ExpectedConditions.elementIsClickable暗示該元素也是「可見,啓用和呈現」。 ExpectedConditions.presenceOfElementLocatedBy似乎只是一個簡單的findElement調用。Selenium中的「可點擊」元素是否意味着它是「可見的和現在的」?
通過查看源代碼,這裏是我幹嘛這麼遠約ExpectedConditions行爲,從方法:
1. findElement() = can throw NoSuchElementException, or WebDriverException
2. elementToBeClickable() = is visible, !null, and enabled, catches
a StaleElementReferenceException
3. visbilityOf() = displayed, catches no exception
4. presenceOfElementLocated() = simple findElement call, catches findElement()
exceptions
5. stalenessOf() = true if findElement succeeds, can catch StaleElementReferenceException,
or findElement() exceptions
6. visibilityOfElementLocated() = same as stalenessOf, can catch
StaleElementReferenceException or the findElement() exceptions
謝謝!謝謝!謝謝!你只是給了我一種方法來爲我的方法編寫單元測試,而不需要外部網站!我非常感謝你!現在我可以編寫單元測試來爲自己證明這些事情。很高興。 – djangofan
:)雖然,我不認爲_clickable_暗示_enabled_,因爲它也可以點擊一個禁用的元素 - 它只是不會做任何事情。 – Faiz
我實際上在WebDriver規範中找到了更詳細的解釋。因此,通過檢查源代碼和規範,我至少能夠對發生的事情有一個模糊的概念。 – djangofan