【问题标题】:How do I click this Bootstrap button in Capybara?如何在 Capybara 中单击此 Bootstrap 按钮?
【发布时间】:2014-05-25 08:00:31
【问题描述】:

如何在 Capybara 中点击这个按钮?

HTML

<div class="btn btn-primary">
    <a href="/carts/7/addresses/new"><span class="glyphicon glyphicon-plus"></span>
      Add an address
    </a>
</div>

我试过了

click_button "Add an Address"
click_button /Add an Address/
click 'Add an Address'
click_link 'Add an Address'

然而他们都说Capybara::ElementNotFound,除了点击,它说NoMethodError

【问题讨论】:

    标签: ruby twitter-bootstrap rspec capybara


    【解决方案1】:

    你是用html代码的小写字母写的,改成大写:Add an address -> Add an Address:

    <a href="/carts/7/addresses/new"><span class="glyphicon glyphicon-plus"></span>
      Add an address
             ^
    </a>
    

    【讨论】:

    • 你是对的。我本可以发誓我与案子相符。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-24
    • 1970-01-01
    • 1970-01-01
    • 2020-02-24
    • 2016-09-28
    • 1970-01-01
    相关资源
    最近更新 更多