Search code examples
rubyruby-on-rails-3capybaracapybara-webkit

How can I click element which matches the text


<div class="list-title-name ng-binding"> NEW LIST </div>
<div class="list-title-name ng-binding"> Things I Like </div>

I want to click the element which matches the text NEW LIST

find("div.list-title-name" == NEW LIST).click #wrong method but want something like this

Can anyone specify a valid capybara method to do this?


Solution

  • The following should do what you want

    find('div.list-title-name', text: 'NEW LIST').click()