class Object
Public Instance Methods
Source
# File lib/capybara/selector/definition/table.rb, line 71 def cell_position(cell) cell.preceding_sibling(:td).count.plus(1) end
Source
# File lib/capybara/selector/definition/button.rb, line 53 def combine_locators(locator, config:) [ XPath.attr(:id).equals(locator), XPath.attr(:name).equals(locator), XPath.attr(:value).is(locator), XPath.attr(:title).is(locator), (XPath.attr(:id) == XPath.anywhere(:label)[XPath.string.n.is(locator)].attr(:for)), (XPath.attr(:'aria-label').is(locator) if config.enable_aria_label), (XPath.attr(config.test_id) == locator if config.test_id) ].compact.inject(&:|) end
Source
# File lib/capybara/selector/definition/label.rb, line 59 def labelable_elements %i[button input keygen meter output progress select textarea] end
Source
# File lib/capybara/selector/definition/button.rb, line 65 def labellable_elements (XPath.self(:input) & XPath.attr(:type).one_of('submit', 'reset', 'image', 'button')) | XPath.self(:button) end
Source
# File lib/capybara/selector/definition/table.rb, line 75 def match_row(row, match_size: false) xp = XPath.descendant(:tr)[ if row.is_a? Hash row_match_cells_to_headers(row) else XPath.descendant(:td)[row_match_ordered_cells(row)] end ] xp = xp[XPath.descendant(:td).count.equals(row.size)] if match_size xp end
Source
# File lib/capybara/selector/definition/table.rb, line 87 def match_row_count(size) XPath.descendant(:tbody).descendant(:tr).count.equals(size) | (XPath.descendant(:tr).count.equals(size) & ~XPath.descendant(:tbody)) end
Source
# File lib/capybara/selector/definition/select.rb, line 74 def options_text(node, **opts, &filter_block) opts[:wait] = false opts[:visible] = false unless node.visible? node.all(:xpath, './/option', **opts, &filter_block).map do |o| o.text((:all if opts[:visible] == false)) end end
Source
# File lib/capybara/selector/definition/table.rb, line 67 def prev_col_position?(cell) XPath.position.equals(cell_position(cell)) end
Source
# File lib/capybara/selector/definition/table.rb, line 92 def row_match_cells_to_headers(row) row.map do |header, cell| header_xp = XPath.ancestor(:table)[1].descendant(:tr)[1].descendant(:th)[XPath.string.n.is(header)] XPath.descendant(:td)[ XPath.string.n.is(cell) & XPath.position.equals(header_xp.preceding_sibling.count.plus(1)) ] end.reduce(:&) end
Source
# File lib/capybara/selector/definition/table.rb, line 101 def row_match_ordered_cells(row) row_conditions = row.map do |cell| XPath.self(:td)[XPath.string.n.is(cell)] end row_conditions.reverse.reduce do |cond, cell| cell[XPath.following_sibling[cond]] end end