Class: CongressForms::Actions::FillIn

Inherits:
Base
  • Object
show all
Defined in:
lib/congress_forms/actions.rb

Instance Attribute Summary

Attributes inherited from Base

#options, #required, #selector, #value

Instance Method Summary collapse

Methods inherited from Base

#escape_css_attribute, #initialize, #inspect, #max_length, #placeholder_value?, #select_options, #submit?

Constructor Details

This class inherits a constructor from CongressForms::Actions::Base

Instance Method Details

#perform(browser, params = {}) ⇒ Object



78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/congress_forms/actions.rb', line 78

def perform(browser, params={})
  if placeholder_value?
    value = params[self.value]&.gsub("\t", "    ") || ""

    maxl = options["max_length"]
    value = value[0, (0.95 * maxl).floor] if maxl
  else
    value = self.value
  end

  browser.find(selector).set(value)
end