class Swamp::Elements

Public Instance Methods

formatter() click to toggle source
# File lib/swamp/collections/elements.rb, line 36
def formatter
  @formatter ||= Swamp::Formatter.new
end
has_class?(element) click to toggle source
# File lib/swamp/collections/elements.rb, line 16
def has_class?(element)
  element['class'] != nil and element['class'] != "" ? true : false
end
has_id?(element) click to toggle source
# File lib/swamp/collections/elements.rb, line 4
def has_id?(element)
  element['id'] != nil and element['id'] != "" ? true : false
end
has_name?(element) click to toggle source
# File lib/swamp/collections/elements.rb, line 8
def has_name?(element)
  element['name'] != nil and element['name'] != "" ? true : false
end
has_no_punctuation?(string) click to toggle source
# File lib/swamp/collections/elements.rb, line 28
def has_no_punctuation?(string)
  string.match(/[.,]/) ? false : true
end
has_valid_id?(element) click to toggle source
# File lib/swamp/collections/elements.rb, line 32
def has_valid_id?(element)
  element["id"].length <= 1 ? false : true
end
has_valid_text?(element) click to toggle source
# File lib/swamp/collections/elements.rb, line 20
def has_valid_text?(element)
  element.text.length >= 3 and has_no_punctuation?(element.text)
end
has_valid_value?(element) click to toggle source
# File lib/swamp/collections/elements.rb, line 24
def has_valid_value?(element)
  element["value"].length >= 3 and has_no_punctuation?(element["value"])
end
has_value?(element) click to toggle source
# File lib/swamp/collections/elements.rb, line 12
def has_value?(element)
  element['value'] != nil and element['value'] != "" ? true : false
end
shine(selector) click to toggle source
# File lib/swamp/collections/elements.rb, line 40
def shine(selector)
  js = JavaScript::Minifier.new.minify
  script = JavaScript::FunctionBuilder.new(js).build_with(selector)
  page.execute_script(script) rescue false
end

Private Instance Methods

set_background_color(selector, color) click to toggle source
# File lib/swamp/collections/elements.rb, line 52
def set_background_color(selector, color)
  page.execute_script %-document.querySelector("#{selector}").style.backgroundColor='#{color}'-
end