【问题标题】:Finding the last element with the same class in Capybara and filling it with some text在 Capybara 中找到具有相同类的最后一个元素并用一些文本填充它
【发布时间】:2013-12-07 16:55:39
【问题描述】:

我有以下标记:

<div class='foo'>
  <form>
    <input class='bar' type='text'>
  </form>
<div/>

<div class='foo'>
  <form>
    <input class='bar' type='text'>
  </form>
</div>

我想在第二个.foo 容器中填写输入。我如何在 Capybara 中实现这一点?

【问题讨论】:

    标签: css ruby-on-rails ruby capybara


    【解决方案1】:

    怎么样:

    within all('.foo').last do
      find('.bar').set 'a value'
    end
    

    检查within 和set。

    【讨论】:

    • 太好了,我不知道within 接受节点作为参数,谢谢
    • 任何想法如何单击既不是第一个也不是最后一个的元素
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-05-04
    • 2017-08-06
    • 1970-01-01
    • 2019-09-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多