Sha256: 5437ca7b360a059c1602389d19bdf6ac53788c4ef055f1b94466107e1263bfec

Contents?: true

Size: 1.53 KB

Versions: 24

Compression:

Stored size: 1.53 KB

Contents

include Gridium

class Gridium::ElementExtensions
  def self.highlight(element)
    Log.debug("Highlighting element...")
    original_border = Driver.execute_script("return arguments[0].style.border", element.element)
    original_background = Driver.execute_script("return arguments[0].style.backgroundColor", element.element)
    Driver.execute_script("arguments[0].style.border='3px solid lime'; return;", element.element)
    Driver.execute_script("arguments[0].style.backgroundColor='lime'; return;", element.element)
    sleep (Gridium.config.highlight_duration)
    Driver.execute_script("arguments[0].style.border='" + original_border + "'; return;", element.element)
    Driver.execute_script("arguments[0].style.backgroundColor='" + original_background + "'; return;", element.element)
  end

  def self.scroll_to(element)
    Log.debug("Scrolling element into view...")
    Driver.execute_script("arguments[0].scrollIntoView(); return;", element.element)
    sleep 1
  end

  def self.hover_over(element)
    Driver.execute_script("var evObj = document.createEvent('MouseEvents'); evObj.initMouseEvent(\"mouseover\",true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); arguments[0].dispatchEvent(evObj);", element.element)
    sleep 2
  end

  def self.hover_away(element)
    Driver.execute_script("var evObj = document.createEvent('MouseEvents'); evObj.initMouseEvent(\"mouseout\",true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); arguments[0].dispatchEvent(evObj);", element.element)
    sleep 1
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
gridium-0.2.2 lib/element_extensions.rb
gridium-0.2.1 lib/element_extensions.rb
gridium-0.2.0 lib/element_extensions.rb
gridium-0.1.21 lib/element_extensions.rb
gridium-0.1.20 lib/element_extensions.rb
gridium-0.1.18 lib/element_extensions.rb
gridium-0.1.17 lib/element_extensions.rb
gridium-0.1.16 lib/element_extensions.rb
gridium-0.1.15 lib/element_extensions.rb
gridium-0.1.14 lib/element_extensions.rb
gridium-0.1.13 lib/element_extensions.rb
gridium-0.1.12 lib/element_extensions.rb
gridium-0.1.11 lib/element_extensions.rb
gridium-0.1.10 lib/element_extensions.rb
gridium-0.1.9 lib/element_extensions.rb
gridium-0.1.8 lib/element_extensions.rb
gridium-0.1.7 lib/element_extensions.rb
gridium-0.1.6 lib/element_extensions.rb
gridium-0.1.5 lib/element_extensions.rb
gridium-0.1.4 lib/element_extensions.rb