Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cucumber - Capybara search for text within table row

I'm trying to search within a single table row for my cucumber test.

I have each row formatted like this:

%tr
  %td= title
  %td= complete
  %td= goal

And I am looking to search within a row with a given title, and check the goal

Is there a simple way to accomplish this?

like image 882
Josh Johnson Avatar asked Nov 22 '11 17:11

Josh Johnson


2 Answers

For anyone else who stumbles on this question, I think a better way to do this is:

find('tr', text: 'My title').should have_content(goal)

This way you're not adding a title attribute when it's not really needed

like image 124
Peter Brown Avatar answered Sep 17 '22 14:09

Peter Brown


I would probably add an attribute to the td you're interested in. Do something like:

%tr
  %td{title= "#{title}"}= title
  %td= complete
  %td= goal

Then you can refer to this question on StackOverflow about finding within a specific element using css.

Capybara, finding within a css element

like image 28
ardavis Avatar answered Sep 21 '22 14:09

ardavis