验证是否有不同的菜单项
我将尝试改善问题。 如何验证菜单中是否包含其他项目:GAR? 我在下面使用了它,它仍然没有用 page.all('select#tbm2')。映射(&:value).should ==%w(regras,gar regras,gae log processamentosos gar/gae)
<div id="tbm2" class="tb">
<div id="TBH_tbm2" onclick="javascript:showMenu('tbm2','tbm2', true, true)" class="tbh">GAR</div>
<div id="TBB_tbm2" class="tbb">
<div onclick="sendEvent(0,event,this,searchImage(this),0,'','1370','Menu','','','.13.3','',''); " class="tbi tbiSel">
<div>
<div class="tbiIcon"><img src="r/std/static/pixel.gif" class="icon icon_config" draggable="false"></div>
</div>
<div>Regras GAR</div>
</div>
<div onclick="sendEvent(0,event,this,searchImage(this),0,'','1370','Menu','','','.13.4','',''); " class="tbi">
<div>
<div class="tbiIcon"><img src="r/std/static/collapse16.gif" class="icon" draggable="false"></div>
</div>
<div>Regras GAE</div>
</div>
<div onclick="sendEvent(0,event,this,searchImage(this),0,'','1370','Menu','','','.13.6','',''); " class="tbi">
<div>
<div class="tbiIcon"><img src="r/std/icons/listini64.png" class="icon" draggable="false"></div>
</div>
<div>Log Processamentos GAR/GAE</div>
</div>
</div>
</div>
</td>
I will try to improve the question.
How to validate if a different item is included in the menu: GAR?
I used it below and it still didn't work
page.all('select#tbm2').map(&:value).should == %w(Regras, GAR Regras, GAE Log Processamentos GAR/GAE)
<div id="tbm2" class="tb">
<div id="TBH_tbm2" onclick="javascript:showMenu('tbm2','tbm2', true, true)" class="tbh">GAR</div>
<div id="TBB_tbm2" class="tbb">
<div onclick="sendEvent(0,event,this,searchImage(this),0,'','1370','Menu','','','.13.3','',''); " class="tbi tbiSel">
<div>
<div class="tbiIcon"><img src="r/std/static/pixel.gif" class="icon icon_config" draggable="false"></div>
</div>
<div>Regras GAR</div>
</div>
<div onclick="sendEvent(0,event,this,searchImage(this),0,'','1370','Menu','','','.13.4','',''); " class="tbi">
<div>
<div class="tbiIcon"><img src="r/std/static/collapse16.gif" class="icon" draggable="false"></div>
</div>
<div>Regras GAE</div>
</div>
<div onclick="sendEvent(0,event,this,searchImage(this),0,'','1370','Menu','','','.13.6','',''); " class="tbi">
<div>
<div class="tbiIcon"><img src="r/std/icons/listini64.png" class="icon" draggable="false"></div>
</div>
<div>Log Processamentos GAR/GAE</div>
</div>
</div>
</div>
</td>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
all('选择#tbm2')
将找到所有&lt; select&gt;
带有tbm2
的ID的元素,其中没有一个在您的HTML中。另外,.value
获取value
元素的属性,但是您拥有所有div
elements,没有值。如果您想使用您正在尝试的方法,那将是另一个选择是使用否定的正则匹配匹配项,类似
另一个选项是使用可以传递给大多数Capybara Finder方法的过滤器块,例如
注意:我正在使用
应该
语法,因为这是您在问题中尝试的,但是您确实应该切换到RSPECS期望
语法all('select#tbm2')
is going to find all<select>
elements with an id oftbm2
, of which there are none in your HTML. Also.value
gets thevalue
property of an element but you have alldiv
elements which don't have a value. If you wanted to use the approach you're trying for it would be something likeAnother option would be to use a negative regex match, something like
Another option would be to use the filter block that can be passed to most Capybara finder methods, like
Note: I'm using the
should
syntax because that's what you attempted in your question, but you really should be switching to RSpecsexpect
syntax nowadays