【问题标题】:selenium RC ruby, wait for hidden element to appear?selenium RC ruby​​,等待隐藏元素出现?
【发布时间】:2010-09-17 09:47:55
【问题描述】:

如何等待隐藏元素出现在页面上?

我尝试了seleum.is_element_present,但它似乎不起作用。

【问题讨论】:

    标签: ruby selenium


    【解决方案1】:

    你想要的是 is_visible 方法。下面将等待 30 秒才可见

    !30.times{ break if (@selenium.is_visible("locator") rescue false); sleep 1 }
    

    【讨论】:

      【解决方案2】:

      wait_for_element(locator, options={})

      等待一个元素出现(在浏览器端等待)。

      【讨论】:

      • present 表示存在于 DOM 中,并不表示可见
      【解决方案3】:

      使用 Watir 时遇到了同样的问题,present? 仅在元素可见时才有效。要等待不可见元素出现,您可以在 Watir 中执行此操作

      Watir::Wait.until { browser.div(:class => "loaded").exists? }
      

      exists? 如果元素在 DOM 中,则返回 true,不关心可见性

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2018-07-31
        • 2018-08-09
        • 2014-05-07
        • 1970-01-01
        • 2020-06-12
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多