为什么不是水豚(2.8.0)能够找到我的文件输入? (输入的场合,如果我检查page.body
来自调试。)水豚无法找到文件输入
And(/^if I add a large image$/) do
within all('.story-title-wrapper').first do
attach_file('.story-item-image-url-file-input-large', test_file)
end
end
# Cucumber error message
And if I add a large image # features/step_definitions/story_steps.rb:466
Unable to find file field ".story-item-image-url-file-input-large" (Capybara::ElementNotFound)
./features/step_definitions/story_steps.rb:468:in `block (2 levels) in <top (required)>'
./features/step_definitions/story_steps.rb:467:in `/^if I add a large image$/'
features/long_form_features.feature:450:in `And if I add a large image'
编辑:我能找到使用ID(attach_file 'story_title_item_image_url_file_input_large', test_file
)输入,但我真的不希望有添加标识到我所有的输入只是为了使这个测试工作。有什么方法可以将现有的类与Capybara一起使用?
谢谢您的回答,但是这不是案件。 – pdoherty926
@ pdoherty926现在更新了答案,我注意到您正在尝试使用类名称 –
Aha,我没有意识到2.10中引入了'class:'选项。我尝试使用它,并遇到一个无效的键错误 - 现在有道理。 – pdoherty926