Cucumber と Capybara を初めて使用します。Web ページでテストをセットアップしましたが、実行しようとするとこのエラーが発生します。
undefined method `locate' for #<Webrat::Session:0x007fdf2ac41c18> (NoMethodError)
./Documents/Work:etc./Raster Media/Cucumber/Klinq Testing/1/features/step_definitions/steps.rb:14:in `/^I make sure the (.*) box is checked$/'
./Documents/Work:etc./Raster Media/Cucumber/Klinq Testing/1/features/account.feature:16:in `And I make sure the vendor[tos] box is checked'
私のウェブページでボックスがチェックされていることを確認するためにそれを取得しようとしています。これが私のステップ定義です:
When /^I make sure the (.*) box is checked$/ do |box|
locate(:css, 'box').set(true)
私のenv.rbファイル:
require 'rspec/expectations'
require 'test/unit/assertions'
require 'capybara'
require 'webrat'
World(Test::Unit::Assertions)
Webrat.configure do |config|
config.mode = :mechanize
end
World do
session = Webrat::Session.new
session.extend(Webrat::Methods)
session.extend(Webrat::Matchers)
session
end
チェックボックスのソースコードは次のとおりです
<input type="checkbox" name="vendor[tos]" value="1" id="vendor[tos]" class="one left">
また、このテストに合格しない場合にチェックボックスをオンに設定する方法を知っておくと役立ちます。
助けてくれた人に感謝します。