Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rspec click a span

I am using rspec to test some pages and would like to use the click method. However the DOM doesn't have the link or button. it's just a span and magically it becomes a link with javascript.

<span class="footerLink feedbackLink">
    Feedback
</span>

rspec offers "click_link" and "click_button"

any ideas how I could click a span?

like image 505
Sarah A Avatar asked Mar 23 '13 20:03

Sarah A


1 Answers

You should be able to do

find('.feedbackLink').click

find returns an Element, and the Element class has a #click method.

Since you probably are handling the click in Javascript, don't forget to add :js => true as a metatag on your test.

like image 86
Mark Rushakoff Avatar answered Sep 29 '22 20:09

Mark Rushakoff