Method: Capybara.modify_selector

Defined in:
lib/capybara.rb

.modify_selector(name) { ... } ⇒ Object

Modify a selector previously created by add_selector. For example, adding a new filter to the :button selector to filter based on button style (a class) might look like this

Capybara.modify_selector(:button) do
  filter (:btn_style, valid_values: [:primary, :secondary]) { |node, style| node[:class].split.include? "btn-#{style}" }
end

Parameters:

  • name (Symbol)

    The name of the selector to modify

Yields:

  • A block executed in the context of the existing Selector

[View source]

200
201
202
# File 'lib/capybara.rb', line 200

def modify_selector(name, &block)
  Capybara::Selector.update(name, &block)
end