Ruby 断言和禁用输入

发布于 2024-08-17 16:36:04 字数 155 浏览 2 评论 0原文

有谁知道如何断言复选框或输入被禁用?我找不到任何表明支持此功能的内容 我正在使用 webrat 和 test/unit 编写黄瓜测试。

我想要一个能够断言禁用的步骤:some_checkbox ||断言_禁用:某些_输入。

或者我可以通过某种方式检查复选框的属性。

Does anyone know how to assert that a checkbox or input is disabled? I can't find anything to indicated that this is supported
I'm writing cucumber tests with webrat and test/unit.

I'd like to have a step that is able to assert_disabled :some_checkbox || assert_disabled :some_input.

Or some way that I can check a property of the checkbox.

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

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

发布评论

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

评论(4

紫瑟鸿黎 2024-08-24 16:36:04
Then /^the "([^\"]*)" field should be disabled$/ do |label|
  field_labeled(label).should be_disabled
end

应该为你做。

Then /^the "([^\"]*)" field should be disabled$/ do |label|
  field_labeled(label).should be_disabled
end

should do it for you.

陌伤ぢ 2024-08-24 16:36:04

这可能对您使用 Webrat 和 Test/Unit 没有帮助,但对于使用 Capybara 的人,您可以使用

Then /^the "([^\"]+)" field should be disabled$/ do |field|
  find_field(field)[:disabled].should == 'disabled'
end

This probably wont help you with Webrat and Test/Unit, but for people using Capybara, you can use

Then /^the "([^\"]+)" field should be disabled$/ do |field|
  find_field(field)[:disabled].should == 'disabled'
end
假装爱人 2024-08-24 16:36:04

你可以尝试一下:

Then /^the "([^\"]*)" field should be disabled$/ do |label|
  field_labeled(label)['disabled'].should == true
end

You could give this a go:

Then /^the "([^\"]*)" field should be disabled$/ do |label|
  field_labeled(label)['disabled'].should == true
end
沉睡月亮 2024-08-24 16:36:04

我得到了皮特的答案,但不得不切换到 field_with_id 。

field_with_id(label).should be_disabled

I got Pete's answer to work but had to switch to field_with_id.

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