【问题标题】:Unable to find field "title" (Capybara::ElementNotFound)找不到字段“标题”(Capybara::ElementNotFound)
【发布时间】:2014-06-23 15:05:40
【问题描述】:

我开始用黄瓜做 BDD。

我的第一个场景是这样写的

Scenario: ...
Given I am on the new event page
And I fill in "title" with "tata"

通过这些步骤

Given /^I am on (.+)$/ do |page_name|
  visit("/event/new")
end

When /^I fill in "([^\"]*)" with "([^\"]*)"$/ do |field, value|
  fill_in(field.gsub(' ', '_'), :with => value)
end

效果很好,很好。 现在,我想使用发送功能访问一个页面。所以我把第一步改成这样。

Given /^I am on (.+)$/ do |page_name|
  self.send("new_event_path".to_sym)
end

页面已找到,但由于未找到某个元素,fill_in 不起作用。

 Unable to find field "title" (Capybara::ElementNotFound)

我不明白为什么它不能与发送功能一起使用?

【问题讨论】:

标签: cucumber capybara


【解决方案1】:

解决办法:

Given /^I am on (.+)$/ do |page_name|
   visit(self.send("new_event_path".to_sym))
end

谢谢戴夫,你的回复对我有帮助:)

埃里克

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-12-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多