让 capybara 通过 selenium 运行所有rspec 测试用例

rspec2 selenium ,capybara 默认配置下只会运行一个it 测试用例,要想让 capybara 通过selenium 运行所有测试用例,(
make Capybara run all your tests in Selenium by setting)则需在 spec/spec_helper.rb 中设置:

Capybara.default_driver = :selenium

或者 运行某些测试用例或者某一组测试用例
To run any example or example group through Selenium, just set :js => true
like this:
1.

 describe "tmptest" ,js=>true   do
    it "visit baidu" do
        visit "http://baidu.com"
         p current_path
    end
    it "visit weibo"  do
       visit "http://weibo.com"
         p current_path
    end
    it "visit bing"  do
       visit "http://bing.com"
         p current_path
    end
  end

2.

 describe "tmtest"  do
    it "visit baidu"  ,js=>true do
        visit "http://baidu.com"
         p current_path
    end
    it "visit baidu"  ,js=>true   do
       visit "http://weibo.com"
         p current_path
    end
    it "visit baidu"  do
       visit "http://bing.com"
         p current_path
    end
  end

see:
http://www.opinionatedprogrammer.com/2011/02/capybara-and-selenium-with-rspec-and-rails-3/
https://github.com/jnicklas/capybara

发表评论