Sha256: f988d1e446696c8aa365db4647ef870e860c175603a238940fded36781a792e9
Contents?: true
Size: 831 Bytes
Versions: 2
Compression:
Stored size: 831 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) & header_xp.boolean & XPath.position.equals(header_xp.preceding_sibling.count.plus(1)) ] xp.where(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| cell.where(xp) } xpath[initial_td[tds]] end end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
blacklight-spotlight-3.6.0.beta8 | vendor/bundle/ruby/3.2.0/gems/capybara-3.40.0/lib/capybara/selector/definition/table_row.rb |
capybara-3.40.0 | lib/capybara/selector/definition/table_row.rb |