2011-01-30 59 views
0

试图填补在文本输入使用webrat黄瓜错误?如果标签包含超过输入

When I fill in "Last name" with "Doe" 
给这个HTML

<label> 
    <span>Last name</span> 
    <input class="title" id="user_last_name" name="user[last_name]" size="30" type="text" /> 
    <small>Some hint text here</small> 
</label> 

将抛出一个

Webrat没有发现场输入元素的Webrat::NotFoundError错误。

如果我删除了<small>标签,该字段就可以找到。

这是一个错误?是否存在解决方法?

回答

1

这不是很漂亮的HTML。它应该是这样的:

<p> 
    <label for='user_last_name'>Last Name</label> 
    <input id='user_last_name' [ other stuff]> 
    <small>Some hint text here</small> 
</p> 

或者在条款的ActionView:

<p> 
    <%= f.label :last_name %> 
    <%= f.text_field :last_name %> 
    <small>Some hint text here</small> 
</p> 
+0

谢谢您的回答。是的,如果它很漂亮,我想这是值得商榷的。这是有效的,尽管(至少在我的脑海里确实很有道理;)),因此不应该抛弃Webrat,或者我看到这个错误? – polarblau 2011-01-30 22:24:54