我正在尝试写一个测试而且我真的很难过。 我正在使用帮助器来呈现链接
module DeleteLinksHelper
def link_to_destroy(object)
opts = {
method: :delete,
remote: true,
id: "#{object.class.name.downcase}-#{object.id}-delete"
### have tried with and without giving it an id
}
link_to object, opts do
content_tag(:span, nil , class: "glyphicon glyphicon-remove")
end
end
end
当我运行服务器时,这一切都正常,它会删除我提供的对象。当我尝试用capybara编写集成测试时,问题就出现了。
Capybara.current_driver = Capybara.javascript_driver = :webkit
# Have tried many ways of selecting/clicking the link and span elements
page.find('span.glyphicon-remove').click
page.find("#component-#{c.id}-delete > span").click
Capybara::Webkit::ClickFailed: Failed to find position for element /html/body/div/div[@id='main']/div[1]/div[2]/div[@id='components-pane']/ul/li[@id='component497695656']/div/a[@id='component-497695656-delete']/span
我刚刚保存了页面,它有完整的html页面。
<a id="component-497695656-delete" data-remote="true" rel="nofollow" data-method="delete" href="/components/497695656">
<span class="glyphicon glyphicon-remove"></span>
</a>
但是如果我同时保存屏幕截图,它只会显示页脚。
呀!这就是整个屏幕截图!这里发生了什么?它与webkit驱动程序有关吗?