rspec - Capybara 1.1.4 -> 2.1.0 升级导致 Poltergeist "ObsoleteNode"错误

标签 rspec capybara phantomjs poltergeist

我有一个运行 Poltergeist 1.0.2 的 Capybara 1.1.4 测试套件,运行在 PhantomJS 1.9.2 之上

今天我尝试将 Capybara 升级到 2.1.0 & Poltergeist 到 1.4.1。大多数测试都有效,但是启用 js 的测试中的一堆 page.find() 元素在 .click 时返回以下错误:

Capybara::Poltergeist::ObsoleteNode: The element you are trying to interact with is either not part of the DOM, or is not currently visible on the page (perhaps display: none is set). It's possible the element has been replaced by another element and you meant to interact with the new element. If so you need to do a new 'find' in order to get a reference to the new element.



奇怪的是:
  • page.find('#my-element') 找到元素就好
  • page.find('#my-element').value 返回正确的值


  • page.find('#my-element').click 返回上面的 'ObsoleteNode' 错误。

  • 有没有人见过这个?我花了几个小时研究了我能想到的每一个疯狂的理论,但没有任何元素可以点击。 (旁注:“#my-element”只是一个例子。有许多不同的元素,有许多不同的 ID 无法点击。)

    任何想法表示赞赏。

    最佳答案

    other answer对我不起作用。我使用了 select_option

    page.find(:css, "#province").find("option[value='Adana']").select_option
    

    关于rspec - Capybara 1.1.4 -> 2.1.0 升级导致 Poltergeist "ObsoleteNode"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20060579/

    相关文章:

    ruby-on-rails - 使用 RSpec 和 Capybara 多次调用访问

    ruby-on-rails - capybara have_field找不到have_selector找到的字段

    ruby-on-rails - 让 Headless Chrome 与 Capybara 一起工作

    scala - 在 Play 框架规范中设置 PhantomJSDriver 上的 Accept-Language

    javascript - 使用 PhantomJS 生成单页 .pdf

    ruby-on-rails - 更改数据库的 Rspec 操作

    ruby-on-rails - 在其他测试中重用 RSpec 测试

    ruby-on-rails - 如何在 Capybara 2.4.1 中访问 c​​ookie 和 session

    ruby-on-rails - rubymine 错误 - 无法在任何来源中找到 capybara-webkit-0.9.0

    css - PhantomJS 跨分页符将单词切成两半