问题描述
我试图使用Cucumber / Capybara / Selenium堆栈测试一个内部编辑器,但我的问题是,编辑器是通过单击一个div而不是链接或按钮激活。我似乎不知道如何得到水豚这样做。是否有办法这样做?您可以通过 。我在 web_steps.rb
中为此添加以下内容以点击div。
当/ ^(?: | I)点击([^] *)$ / do | selector |
find(selector).click
end
还有看起来启用hover即使不使用Selenium。 / p>
这也很可能是你需要装饰你的功能/场景与Capybara提供的 @javascript
标签。 p>
I am trying to test an inplace editor using Cucumber/Capybara/Selenium stack, but my problem is that the editor is activated by clicking a div and not a link or button. I can not seem to figure out how to get Capybara to do this. Is there a way of doing this?
You can click on an element via Capybara::Element.click
. I add the following for this in my web_steps.rb
to click on divs.
When /^(?:|I )click within "([^"]*)"$/ do |selector|
find(selector).click
end
There is also Element.trigger('mouseover')
which appears to enable hover albeit not working with Selenium.
It is also very likely you will need to decorate your feature/scenario with Capybara's provided @javascript
tag.
这篇关于黄瓜和水豚,单击非链接或按钮元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!