Sha256: 0b744a929df3c3e2ca715c278a6fd95bfe68d4ffb04025a1c23e11b255952d6e

Contents?: true

Size: 799 Bytes

Versions: 29

Compression:

Stored size: 799 Bytes

Contents

# frozen_string_literal: true

Capybara.add_selector(:table_row, locator_type: [Array, Hash]) do
  xpath do |locator|
    xpath = XPath.descendant(:tr)
    if locator.is_a? Hash
      locator.reduce(xpath) do |xp, (header, cell)|
        header_xp = XPath.ancestor(:table)[1].descendant(:tr)[1].descendant(:th)[XPath.string.n.is(header)]
        cell_xp = XPath.descendant(:td)[
          XPath.string.n.is(cell) & XPath.position.equals(header_xp.preceding_sibling.count.plus(1))
        ]
        xp[cell_xp]
      end
    else
      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| xp[cell] }
      xpath[initial_td[tds]]
    end
  end
end

Version data entries

29 entries across 26 versions & 3 rubygems

Version Path
tdiary-5.1.3 vendor/bundle/ruby/2.7.0/gems/capybara-3.33.0/lib/capybara/selector/definition/table_row.rb
tdiary-5.1.3 vendor/bundle/ruby/2.6.0/gems/capybara-3.32.2/lib/capybara/selector/definition/table_row.rb
capybara-3.33.0 lib/capybara/selector/definition/table_row.rb
tdiary-5.1.2 vendor/bundle/ruby/2.7.0/gems/capybara-3.32.2/lib/capybara/selector/definition/table_row.rb
tdiary-5.1.2 vendor/bundle/ruby/2.6.0/gems/capybara-3.29.0/lib/capybara/selector/definition/table_row.rb
capybara-3.32.2 lib/capybara/selector/definition/table_row.rb
capybara-3.32.1 lib/capybara/selector/definition/table_row.rb
capybara-3.32.0 lib/capybara/selector/definition/table_row.rb
tdiary-5.1.1 vendor/bundle/ruby/2.6.0/gems/capybara-3.29.0/lib/capybara/selector/definition/table_row.rb
tdiary-5.1.1 vendor/bundle/ruby/2.7.0/gems/capybara-3.31.0/lib/capybara/selector/definition/table_row.rb
capybara-3.31.0 lib/capybara/selector/definition/table_row.rb
capybara-3.30.0 lib/capybara/selector/definition/table_row.rb
tdiary-5.1.0 vendor/bundle/gems/capybara-3.29.0/lib/capybara/selector/definition/table_row.rb
chatops-rpc-0.0.2 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/capybara-3.29.0/lib/capybara/selector/definition/table_row.rb
chatops-rpc-0.0.1 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/capybara-3.29.0/lib/capybara/selector/definition/table_row.rb
capybara-3.29.0 lib/capybara/selector/definition/table_row.rb
capybara-3.28.0 lib/capybara/selector/definition/table_row.rb
capybara-3.27.0 lib/capybara/selector/definition/table_row.rb
capybara-3.26.0 lib/capybara/selector/definition/table_row.rb
capybara-3.25.0 lib/capybara/selector/definition/table_row.rb