首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >硒中的“可点击”元素是否也意味着它是“可见的和存在的”?

问硒中的“可点击”元素是否也意味着它是“可见的和存在的”?
EN

Stack Overflow用户
提问于 2014-03-26 22:46:25
回答 2查看 3.2K关注 0票数 4

在Selenium框架中,ExpectedConditions.elementIsClickable是否意味着元素也是“可见的、启用的和呈现的”。ExpectedConditions.presenceOfElementLocatedBy本身似乎只是一个简单的findElement调用。

通过查看源代码,下面是到目前为止我从方法中所看到的关于ExpectedConditions行为的一些信息:

代码语言:javascript
复制
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
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-03-26 23:46:50

是的,可点击元素需要元素是可见的。如果隐藏元素,Click()将失败并抛出一个ElementNotVisibleException。

示例:对于下面隐藏的span,Click()将抛出带有消息Element is not currently visible and so may not be interacted with的ElementNotVisibleException。

代码语言:javascript
复制
var driver = new FirefoxDriver();
driver.Navigate().GoToUrl("data:text/html,<span id=\"hello\" style=\"display:none;\">Hello</span>");
driver.FindElement(By.Id("hello")).Click();
票数 3
EN

Stack Overflow用户

发布于 2014-03-31 20:10:34

可点击意味着该元素是可见的并启用的。显示并启用另一个words元素。

您可以随时检查ExpectedConditions实现,以防有任何疑问。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22674640

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档