一些_路径" />

水豚 rspec 匹配器相当于 response.should have_selector "form", :action =>一些_路径

发布于 2025-01-02 12:15:50 字数 275 浏览 1 评论 0 原文

水豚中是否有一个匹配器可以检查是否存在具有特定操作的表单?我希望能够这样说:

page.should have_form :action => some_action

看起来 rspec-html-matchers gem 可以满足我的需要,甚至更多,但我觉得奇怪的是 Capybara rspec 匹配器不会提供类似的东西。我错过了什么吗?

Is there a matcher in capybara that will check for the presence of a form with a particular action? I'd like to be able to say something like this:

page.should have_form :action => some_action

It looks like the rspec-html-matchers gem does what I need, and more, but I find it strange that Capybara rspec matchers wouldn't provide something like it. Am I missing something?

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

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

发布评论

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

评论(2

铁憨憨 2025-01-09 12:15:50

您可以使用 xpath 节点匹配器:

has_xpath?("//form[@action='/some_action']")

http://rubydoc .info/github/jnicklas/capybara/Capybara/Node/Matchers#has_xpath%3F-instance_method

You could use the xpath node matcher:

has_xpath?("//form[@action='/some_action']")

http://rubydoc.info/github/jnicklas/capybara/Capybara/Node/Matchers#has_xpath%3F-instance_method

怪异←思 2025-01-09 12:15:50

或者您可以使用常规匹配器,例如 have_css()

have_css("form[action='/users/new']")

Or you can use the regular matchers e.g. have_css()

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