Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rspec Target Font Awesome Icon Link

Is there a way to have rspec click a specific font awesome icon? I'm very new to rspec so I apologize if this is a very basic question.

I tried click_link '.fa-envelope' but it seems like that is looking for the name of the link.

Any ideas?

EDIT:

Here's the html of the link I'm trying to click:

  <div class="col-sm-4 align-center">
    <a class="email-link" href="/contact"><i class="fa fa-envelope"></i></a>
  </div>
like image 508
Tom Hammond Avatar asked Dec 02 '22 18:12

Tom Hammond


2 Answers

You also can use title attribute :

<div class="col-sm-4 align-center">
  <a class="email-link" href="/contact" title="Send email"><i class="fa fa-envelope"></i></a>
</div>

Then in your feature spec you can write :

click_link 'Send email'

Hope this helped !

like image 130
kevcha Avatar answered Dec 30 '22 07:12

kevcha


Assuming you use capybara so you can use finders instead:

find(".email-link").find(".fa-envelope").click

http://rubydoc.info/github/jnicklas/capybara/master/Capybara/Node/Finders

like image 37
phts Avatar answered Dec 30 '22 06:12

phts