在Selenium框架中,ExpectedConditions.elementIsClickable是否意味着元素也是“可见的、启用的和呈现的”。ExpectedConditions.presenceOfElementLocatedBy本身似乎只是一个简单的findElement调用。
通过查看源代码,下面是到目前为止我从方法中所看到的关于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发布于 2014-03-26 23:46:50
是的,可点击元素需要元素是可见的。如果隐藏元素,Click()将失败并抛出一个ElementNotVisibleException。
示例:对于下面隐藏的span,Click()将抛出带有消息Element is not currently visible and so may not be interacted with的ElementNotVisibleException。
var driver = new FirefoxDriver();
driver.Navigate().GoToUrl("data:text/html,<span id=\"hello\" style=\"display:none;\">Hello</span>");
driver.FindElement(By.Id("hello")).Click();发布于 2014-03-31 20:10:34
可点击意味着该元素是可见的并启用的。显示并启用另一个words元素。
您可以随时检查ExpectedConditions实现,以防有任何疑问。
https://stackoverflow.com/questions/22674640
复制相似问题