如何用cucumber和webrat处理隐藏字段?

发布于 2024-08-29 04:14:07 字数 131 浏览 4 评论 0原文

我必须设置一个选择日期字段,并丢弃月份和日期。因此,月份和日期隐藏在表单中,这导致在执行 Cucumber 场景时出现“# (NoMethodError) 的未定义方法‘选项’”。

我怎样才能解决这个问题并将年份正确地纳入黄瓜步骤?

I have to set a select date field with the month and day discarded. So Month and day are hidden in the form which caused a "undefined method `options' for # (NoMethodError)" when executing the cucumber scenario.

How can i solve this issue and get the year correctly into the cucumber step ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

多彩岁月 2024-09-05 04:14:07

好吧,我找到了一个解决方案:
定义我自己的黄瓜步骤,我使用 webrat set_hidden_​​field 方法,如下所示:

When /^I select "([^\"]*)" as the stuff year$/ do |arg1|
  date = Date.parse(arg1)
  set_hidden_field 'stuff_year_2i', :to => date.day
  set_hidden_field 'stuff_year_3i', :to => date.month
  select(date.year, :from => 'stuff_year_1i')
end

希望这可以帮助某人

well i found a solution :
Define my own cucumber steps into which i use the webrat set_hidden_field method like this :

When /^I select "([^\"]*)" as the stuff year$/ do |arg1|
  date = Date.parse(arg1)
  set_hidden_field 'stuff_year_2i', :to => date.day
  set_hidden_field 'stuff_year_3i', :to => date.month
  select(date.year, :from => 'stuff_year_1i')
end

Hope this can help someone

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文