我正在使用rspec测试我的rails应用程序,我在Capybara点击时遇到了一些麻烦: 这是我的规范:
#!/bin/env ruby
# encoding: utf-8
require 'user'
require 'rails_helper'
describe User do
before(:all) do
shop = Shop.create(:shop_no => '2401', :shop_name => 'Yamaha')
link = Link.create(:name => "location")
@agent = User.create(:user_id => '1992112-1234', :password=> 'sa1234',
:name => 'sa1234', :uid=> '0000000000002',
:shop_no => '2401')
login(@agent)
end
...
it "logout sucess in menu" do
visit "welcome/menu"
click_on('Button')
end
...
而且,这是我寻找'Button'的页面
<div class="medium-4 medium-centered row" align="center" style="padding: 45px; padding-top: 0px">
<div class="medium-10 medium-centered columns">
<div class="medium-10 medium-centered row" style="margin-bottom: 8px">
<a href="save" id="but" class="button expand" />発注</a>
</div>
<div class="row" style="border: 1px solid #008cba; border-right: 0px; border-radius: 5px 5px; margin-bottom: 8px">
<div class="columns small-2" style="margin-top: .9em">
仕入
</div>
<div class="small-10 columns">
<div class="row" style="margin-bottom: 8px">
<a href="save" class="button expand"/>Button</a>
</div>
<div class="row">
<a href="save" class="button expand"/>直接仕入</a>
</div>
</div>
</div>
</div>
当我运行规范时,我有这个错误:
请!帮我解决这个问题:)
答案 0 :(得分:0)
还有click_button选项你也可以尝试,我希望这个链接对你有帮助http://www.rubydoc.info/github/jnicklas/capybara