网络老鼠 +野科切 + CSS 选择器 +空格=噩梦

发布于 2024-09-19 21:24:25 字数 1130 浏览 8 评论 0原文

我需要使用 Cucumber/Webrat 测试此按钮的存在:

<%=submit_tag 'Get it'%>

但是当我使用此自定义步骤时:

And I should see a button with a value of "Get it"

即:

Then /^I should see a button with a value of "([^\"]*)"$/ do |value|
 response.should have_selector("form input[value=#{value}]")
end

我得到:

    And I should see a button with a value of "Get it"                       # features/step_definitions/common_steps.rb:181
      unexpected ' ' after 'includesGet' (Nokogiri::CSS::SyntaxError)
      /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/racc/parser.rb:99:in `_racc_do_parse_c'
      /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/racc/parser.rb:99:in `__send__'
      /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/racc/parser.rb:99:in `do_parse'
      ./features/step_definitions/common_steps.rb:182:in `/^I should see a button with a value of "([^\"]*)"$/'

当我使用一个单词值测试按钮时,它可以工作,所以它是“Get”和“it”之间的空格。

有想法吗?

谢谢

I need to test with Cucumber/Webrat the presence of this button:

<%=submit_tag 'Get it'%>

But when I use this custom step:

And I should see a button with a value of "Get it"

that is:

Then /^I should see a button with a value of "([^\"]*)"$/ do |value|
 response.should have_selector("form input[value=#{value}]")
end

I get:

    And I should see a button with a value of "Get it"                       # features/step_definitions/common_steps.rb:181
      unexpected ' ' after 'includesGet' (Nokogiri::CSS::SyntaxError)
      /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/racc/parser.rb:99:in `_racc_do_parse_c'
      /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/racc/parser.rb:99:in `__send__'
      /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/racc/parser.rb:99:in `do_parse'
      ./features/step_definitions/common_steps.rb:182:in `/^I should see a button with a value of "([^\"]*)"$/'

When I test a button with a ONE WORD value it works, so it's the space between "Get" and "it".

Ideas?

Thanks

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

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

发布评论

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

评论(2

无力看清 2024-09-26 21:24:25
And I should see a button named "Get it"

custom_steps.rb

Then /^I should see a button named "([^\"]*)"$/ do |name|
 response.should have_xpath("//input[@type='submit' and @value='#{name}']")
end

感谢 http://www.vermonster.com/ 2009/12/16/黄瓜研讨会回顾/

And I should see a button named "Get it"

custom_steps.rb

Then /^I should see a button named "([^\"]*)"$/ do |name|
 response.should have_xpath("//input[@type='submit' and @value='#{name}']")
end

Thanks to http://www.vermonster.com/2009/12/16/cucumber-workshop-recap/

南薇 2024-09-26 21:24:25

对我来说,这似乎是 Nokogiri 的一个问题:

page.search("input[value='Next Batch']")   # => Nokogiri::CSS::SyntaxError
page.search("//input[@value='Next Batch']") # => Okay

This appears to specifically be a problem with Nokogiri, for me:

page.search("input[value='Next Batch']")   # => Nokogiri::CSS::SyntaxError
page.search("//input[@value='Next Batch']") # => Okay
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文