Class: Sapphire::Plugins::Highlighter

Inherits:
Plugin show all
Defined in:
lib/sapphire/Plugins/Highlighters/Highlighter.rb

Instance Attribute Summary

Attributes inherited from Plugin

#method, #object

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Plugin

observe, #observes

Constructor Details

#initializeHighlighter

Returns a new instance of Highlighter.



6
7
8
9
10
11
# File 'lib/sapphire/Plugins/Highlighters/Highlighter.rb', line 6

def initialize

  observes :class => WebAbstractions::RubySeleniumWebDriver,
           :method => :FindElement

end

Class Method Details

.IsObserverObject



33
34
35
# File 'lib/sapphire/Plugins/Highlighters/Highlighter.rb', line 33

def self.IsObserver()
  true
end

Instance Method Details

#Before(instance, method, args) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/sapphire/Plugins/Highlighters/Highlighter.rb', line 13

def Before(instance, method, args)
  return if ENV["highlighter"] != "true"

  discriminator = args[0]
  selector = args[1]

  begin
    if(discriminator == :id)
      instance.ExecuteScript("document.getElementById('#{selector}').style.backgroundColor = '#FFF467'; ")
    elsif (discriminator == :name )
      instance.ExecuteScript("document.getElementByName('#{selector}').style.backgroundColor = '#FFF467'; ")
    elsif (discriminator == :xpath)
      instance.ExecuteScript("document.evaluate( '#{selector}', document, null, XPathResult.ANY_TYPE, null ).iterateNext().style.backgroundColor = '#FFF467'; ")
    end

  rescue
  end

end