diff --git a/lib/capybara/selector/definition/table_row.rb b/lib/capybara/selector/definition/table_row.rb index 6e9a9a73a..7517595fa 100644 --- a/lib/capybara/selector/definition/table_row.rb +++ b/lib/capybara/selector/definition/table_row.rb @@ -11,11 +11,13 @@ ] xp.where(cell_xp) end - else + elsif locator.is_a? Array initial_td = XPath.descendant(:td)[XPath.string.n.is(locator.shift)] tds = locator.reverse.map { |cell| XPath.following_sibling(:td)[XPath.string.n.is(cell)] } .reduce { |xp, cell| cell.where(xp) } xpath[initial_td[tds]] + else + xpath end end end diff --git a/lib/capybara/spec/session/has_table_spec.rb b/lib/capybara/spec/session/has_table_spec.rb index 42ac1775e..b947104eb 100644 --- a/lib/capybara/spec/session/has_table_spec.rb +++ b/lib/capybara/spec/session/has_table_spec.rb @@ -131,6 +131,13 @@ expect(@session.find(:table, 'Horizontal Headers')).not_to have_selector(:table_row, %w[Walpole Thomas]) expect(@session.find(:table, 'Horizontal Headers')).not_to have_selector(:table_row, %w[Other]) end + + it 'should find row by all rows without locator values' do + table = @session.find(:table, 'Horizontal Headers') + + expect(table).to have_selector(:table_row) + expect(table).to have_selector(:table_row, count: 6) + end end Capybara::SpecHelper.spec '#has_no_table?' do