水豚找不到按名称提交按钮

发布于 2024-10-10 01:56:57 字数 644 浏览 0 评论 0原文

我在尝试从 webrat 切换到水豚时发生了一些奇怪的情况。错误是这样的:

And I press "Create floob"
    # features/step_definitions/web_steps.rb:27
    no button with value or id or text 'Create floob' found (Capybara::ElementNotFound)

我的应用程序中的 html 看起来像这样:

<fieldset class="buttons">
  <ol>
    <input id="floob_submit" name="commit" type="submit" value="Create floob" /> 
  </ol>
</fieldset>

我本以为水豚会查看页面上按钮的 value ,并且阅读文档,情况似乎确实如此,但它不起作用!如果我将 cuke 文件中的行更改为 And I press "floob_submit" 一切正常,但我不想更改我的所有功能...

有谁对为什么会发生这种情况有任何想法如果有解决办法吗?谢谢朋友们!

I have some weirdness occurring while trying to switch from webrat to capybara. The error is this:

And I press "Create floob"
    # features/step_definitions/web_steps.rb:27
    no button with value or id or text 'Create floob' found (Capybara::ElementNotFound)

The html in my app looks like this:

<fieldset class="buttons">
  <ol>
    <input id="floob_submit" name="commit" type="submit" value="Create floob" /> 
  </ol>
</fieldset>

I would have thought that capybara would look at the value of the buttons on the page, and reading the documentation this does seem to be the case, but it's not working! If I change the line in my cuke file to And I press "floob_submit" everything works, but I'd rather not change all my features...

Does anyone have any thoughts on why this might be happening and if there's a fix? Thanks friends!

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

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

发布评论

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

评论(1

生生漫 2024-10-17 01:56:57

我唯一能看到的是您没有将输入包装在

  • 中。这可能足以让 DOM 造成您的问题。

    The only thing I can see is that you aren't wrapping your input in an <li></li>. This might be confusing enough for the DOM to cause your problem.

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