即使对于简单的场景,我也无法使 xpath 与 capybara 一起使用,例如我有:
<div id="drawer-container" role="application" class="drawers-2">
<div class="drawer" id="drawer-1">
<h2 role="tab" aria-controls="tabpanel-highlights">
<a href="#" class="drawer-toggle" role="button">
<span>Featured</span>
<span class="context blq-hide">section collapsed</span>
</a>
</h2>
但是当我用 Capybara 尝试以下操作时:
find(:xpath, "div[@id='drawer-1' and @class='drawer']").click
然后它失败说:
Unable to find xpath "div[@id='drawer-1' and @class='drawer']" (Capybara::ElementNotFound)
我读到这可能是由于 webrat,但我没有那个宝石。我的水豚版本是 2.0.1
知道什么可能导致这个问题吗?
谢谢!