【问题标题】:Capybara Poltergeist get element textCapybara Poltergeist 获取元素文本
【发布时间】:2013-05-12 21:05:17
【问题描述】:

我有一行代码可以使用除 poltergeist 之外的任何驱动程序获取页面上元素的内容。这是 poltergeist 的预期行为吗?如果是这样,我怎样才能以与 poltergeist 一起使用的方式做到这一点?

这是红宝石

page.find( item_price_selector(3) ).native.text

这是错误

Failure/Error: price = page.find( item_price_selector(3) ).native.text
NoMethodError:
   undefined method `text' for #<Capybara::Poltergeist::Node:0xb07db1c>

【问题讨论】:

    标签: capybara poltergeist


    【解决方案1】:
    page.find( item_price_selector(3) ).native.text
    

    native 是不必要的。删除它并使其在所有驱动程序中正确运行

    page.find( item_price_selector(3) ).text
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-08
      • 1970-01-01
      • 2016-07-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多