使用:Rails 3.2.13、cucumber (1.2.3)、selenium-webdriver (2.31.0)、capybara (2.0.3)
我在移动网站上工作,需要使用 selenium 来测试 javascript 功能。但是,当我尝试一起运行黄瓜测试时,紧随@javascript
标记测试之后的测试失败了:
The action 'assets' could not be found for SiteController (AbstractController::ActionNotFound)
/Users/emai/.rvm/gems/ruby-1.9.3-p362@sherry3/gems/actionpack-3.2.13/lib/abstract_controller/base.rb:116:in `process'
/Users/emai/.rvm/gems/ruby-1.9.3-p362@sherry3/gems/actionpack-3.2.13/lib/abstract_controller/rendering.rb:45:in `process'
/Users/emai/.rvm/gems/ruby-1.9.3-p362@sherry3/gems/actionpack-3.2.13/lib/action_controller/metal.rb:203:in `dispatch'
/Users/emai/.rvm/gems/ruby-1.9.3-p362@sherry3/gems/actionpack-3.2.13/lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
/Users/emai/.rvm/gems/ruby-1.9.3-p362@sherry3/gems/actionpack-3.2.13/lib/action_controller/metal.rb:246:in `block in action'
/Users/emai/.rvm/gems/ruby-1.9.3-p362@sherry3/gems/actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:73:in `call'
/Users/emai/.rvm/gems/ruby-1.9.3-p362@sherry3/gems/actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
/Users/emai/.rvm/gems/ruby-1.9.3-p362@sherry3/gems/actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:36:in `call'
/Users/emai/.rvm/gems/ruby-1.9.3-p362@sherry3/gems/journey-1.0.4/lib/journey/router.rb:68:in `block in call'
/Users/emai/.rvm/gems/ruby-1.9.3-p362@sherry3/gems/journey-1.0.4/lib/journey/router.rb:56:in `each'
/Users/emai/.rvm/gems/ruby-1.9.3-p362@sherry3/gems/journey-1.0.4/lib/journey/router.rb:56:in `call'
/Users/emai/.rvm/gems/ruby-1.9.3-p362@sherry3/gems/actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:612:in `call'
/Users/emai/.rvm/gems/ruby-1.9.3-p362@sherry3/gems/warden-1.2.1/lib/warden/manager.rb:35:in `block in call'
/Users/emai/.rvm/gems/ruby-1.9.3-p362@sherry3/gems/warden-1.2.1/lib/warden/manager.rb:34:in `catch'
/Users/emai/.rvm/gems/ruby-1.9.3-p362@sherry3/gems/warden-1.2.1/lib/warden/manager.rb:34:in `call'
/Users/emai/.rvm/gems/ruby-1.9.3-p362@sherry3/gems/actionpack-3.2.13/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
/Users/emai/.rvm/gems/ruby-1.9.3-p362@sherry3/gems/rack-1.4.5/lib/rack/etag.rb:23:in `call'
/Users/emai/.rvm/gems/ruby-1.9.3-p362@sherry3/gems/rack-1.4.5/lib/rack/conditionalget.rb:25:in `call'
/Users/emai/.rvm/gems/ruby-1.9.3-p362@sherry3/gems/actionpack-3.2.13/lib/action_dispatch/middleware/head.rb:14:in `call'
/Users/emai/.rvm/gems/ruby-1.9.3-p362@sherry3/gems/actionpack-3.2.13/lib/action_dispatch/middleware/params_parser.rb:21:in `call'
/Users/emai/.rvm/gems/ruby-1.9.3-p362@sherry3/gems/actionpack-3.2.13/lib/action_dispatch/middleware/flash.rb:242:in `call'
/Users/emai/.rvm/gems/ruby-1.9.3-p362@sherry3/gems/rack-1.4.5/lib/rack/session/abstract/id.rb:210:in `context'
/Users/emai/.rvm/gems/ruby-1.9.3-p362@sherry3/gems/rack-1.4.5/lib/rack/session/abstract/id.rb:205:in `call'
/Users/emai/.rvm/gems/ruby-1.9.3-p362@sherry3/gems/actionpack-3.2.13/lib/action_dispatch/middleware/cookies.rb:341:in `call'
/Users/emai/.rvm/gems/ruby-1.9.3-p362@sherry3/gems/activerecord-3.2.13/lib/active_record/query_cache.rb:64:in `call'
/Users/emai/.rvm/gems/ruby-1.9.3-p362@sherry3/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
/Users/emai/.rvm/gems/ruby-1.9.3-p362@sherry3/gems/actionpack-3.2.13/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
/Users/emai/.rvm/gems/ruby-1.9.3-p362@sherry3/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:405:in `_run__1123647381172448721__call__979271738568178806__callbacks'
/Users/emai/.rvm/gems/ruby-1.9.3-p362@sherry3/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:405:in `__run_callback'
/Users/emai/.rvm/gems/ruby-1.9.3-p362@sherry3/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
/Users/emai/.rvm/gems/ruby-1.9.3-p362@sherry3/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:81:in `run_callbacks'
/Users/emai/.rvm/gems/ruby-1.9.3-p362@sherry3/gems/actionpack-3.2.13/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
/Users/emai/.rvm/gems/ruby-1.9.3-p362@sherry3/gems/actionpack-3.2.13/lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
/Users/emai/.rvm/gems/ruby-1.9.3-p362@sherry3/gems/actionpack-3.2.13/lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
/Users/emai/.rvm/gems/ruby-1.9.3-p362@sherry3/gems/actionpack-3.2.13/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
/Users/emai/.rvm/gems/ruby-1.9.3-p362@sherry3/gems/cucumber-rails-1.3.1/lib/cucumber/rails/action_controller.rb:10:in `call'
/Users/emai/.rvm/gems/ruby-1.9.3-p362@sherry3/gems/railties-3.2.13/lib/rails/rack/logger.rb:32:in `call_app'
/Users/emai/.rvm/gems/ruby-1.9.3-p362@sherry3/gems/railties-3.2.13/lib/rails/rack/logger.rb:16:in `block in call'
/Users/emai/.rvm/gems/ruby-1.9.3-p362@sherry3/gems/activesupport-3.2.13/lib/active_support/tagged_logging.rb:22:in `tagged'
/Users/emai/.rvm/gems/ruby-1.9.3-p362@sherry3/gems/railties-3.2.13/lib/rails/rack/logger.rb:16:in `call'
/Users/emai/.rvm/gems/ruby-1.9.3-p362@sherry3/gems/actionpack-3.2.13/lib/action_dispatch/middleware/request_id.rb:22:in `call'
/Users/emai/.rvm/gems/ruby-1.9.3-p362@sherry3/gems/rack-1.4.5/lib/rack/methodoverride.rb:21:in `call'
/Users/emai/.rvm/gems/ruby-1.9.3-p362@sherry3/gems/rack-1.4.5/lib/rack/runtime.rb:17:in `call'
/Users/emai/.rvm/gems/ruby-1.9.3-p362@sherry3/gems/activesupport-3.2.13/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
/Users/emai/.rvm/gems/ruby-1.9.3-p362@sherry3/gems/rack-1.4.5/lib/rack/lock.rb:15:in `call'
/Users/emai/.rvm/gems/ruby-1.9.3-p362@sherry3/gems/actionpack-3.2.13/lib/action_dispatch/middleware/static.rb:63:in `call'
/Users/emai/.rvm/gems/ruby-1.9.3-p362@sherry3/gems/railties-3.2.13/lib/rails/engine.rb:479:in `call'
/Users/emai/.rvm/gems/ruby-1.9.3-p362@sherry3/gems/railties-3.2.13/lib/rails/application.rb:223:in `call'
/Users/emai/.rvm/gems/ruby-1.9.3-p362@sherry3/gems/rack-1.4.5/lib/rack/builder.rb:134:in `call'
/Users/emai/.rvm/gems/ruby-1.9.3-p362@sherry3/gems/rack-1.4.5/lib/rack/urlmap.rb:64:in `block in call'
/Users/emai/.rvm/gems/ruby-1.9.3-p362@sherry3/gems/rack-1.4.5/lib/rack/urlmap.rb:49:in `each'
/Users/emai/.rvm/gems/ruby-1.9.3-p362@sherry3/gems/rack-1.4.5/lib/rack/urlmap.rb:49:in `call'
/Users/emai/.rvm/gems/ruby-1.9.3-p362@sherry3/gems/capybara-2.0.3/lib/capybara/server.rb:19:in `call'
/Users/emai/.rvm/gems/ruby-1.9.3-p362@sherry3/gems/rack-1.4.5/lib/rack/handler/webrick.rb:59:in `service'
/Users/emai/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
/Users/emai/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
/Users/emai/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'
我猜assets
我的通配符路由中触发了某些东西match ':action(/:id)' => "site"
。但是,当我在 textmate 中执行命令 + shift + F (在整个项目中查找关键字)时,我只能在视图中找到对资产的一个引用,并且将其注释掉并没有任何作用。
我还尝试在我的 env 文件中更改 cucumber 以使用截断而不是事务:
从:
Cucumber::Rails::Database.javascript_strategy = :transaction
到:
Cucumber::Rails::Database.javascript_strategy = :truncation
但没有任何效果。这是一个错误吗?还是我的测试/视图有问题?我可以尝试用 javascript 测试硒的另一种选择吗?
更新:尝试安装 capybara-webkit,但遇到错误。
Nets-Mac-Pro:sl-mobile emai$ bundle install
...
...
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Users/emai/.rvm/rubies/ruby-1.9.3-p362/bin/ruby extconf.rb
Command 'qmake -spec macx-g++' not available
Gem files will remain installed in /Users/emai/.rvm/gems/ruby-1.9.3-p362@sherry3/gems/capybara-webkit-0.14.2 for inspection.
Results logged to /Users/emai/.rvm/gems/ruby-1.9.3-p362@sherry3/gems/capybara-webkit-0.14.2/./gem_make.out