Sha256: 7c74715ef8b1286473d4121f4caa723e0df3bf04ef0fe26c902685954440edd2

Contents?: true

Size: 1018 Bytes

Versions: 7

Compression:

Stored size: 1018 Bytes

Contents

# frozen_string_literal: true

Capybara.add_selector(:fillable_field, locator_type: [String, Symbol]) do
  label 'field'
  xpath do |locator, allow_self: nil, **options|
    xpath = XPath.axis(allow_self ? :"descendant-or-self" : :descendant, :input, :textarea)[
      !XPath.attr(:type).one_of('submit', 'image', 'radio', 'checkbox', 'hidden', 'file')
    ]
    locate_field(xpath, locator, options)
  end

  expression_filter(:type) do |expr, type|
    type = type.to_s
    if type == 'textarea'
      expr.self(type.to_sym)
    else
      expr[XPath.attr(:type) == type]
    end
  end

  filter_set(:_field, %i[disabled multiple name placeholder valid])

  node_filter(:with) do |node, with|
    val = node.value
    (with.is_a?(Regexp) ? with.match?(val) : val == with.to_s).tap do |res|
      add_error("Expected value to be #{with.inspect} but was #{val.inspect}") unless res
    end
  end

  describe_node_filters do |**options|
    " with value #{options[:with].to_s.inspect}" if options.key?(:with)
  end
end

Version data entries

7 entries across 7 versions & 3 rubygems

Version Path
tdiary-5.1.2 vendor/bundle/ruby/2.6.0/gems/capybara-3.29.0/lib/capybara/selector/definition/fillable_field.rb
tdiary-5.1.1 vendor/bundle/ruby/2.6.0/gems/capybara-3.29.0/lib/capybara/selector/definition/fillable_field.rb
tdiary-5.1.0 vendor/bundle/gems/capybara-3.29.0/lib/capybara/selector/definition/fillable_field.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/fillable_field.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/fillable_field.rb
capybara-3.29.0 lib/capybara/selector/definition/fillable_field.rb
capybara-3.28.0 lib/capybara/selector/definition/fillable_field.rb