I am trying to write a test and I am getting really stumped. I am using a helper to render a link
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
this all works fine when I run the server it deletes the object i hand it. the problems start when I try to write an integration test with 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
I saved the page just before and it has the entire page of html as it should be.
<a id="component-497695656-delete" data-remote="true" rel="nofollow" data-method="delete" href="/components/497695656">
<span class="glyphicon glyphicon-remove"></span>
</a>
However if i save a screenshot at the same time it only shows the footer.
Yeah!!! That's the whole screenshot! Whats going on here? Does it have to do with the webkit driver?