Class: Sapphire::Plugins::PassedControlHighlighter

Inherits:
Plugin show all
Defined in:
lib/sapphire/Plugins/Highlighters/PassedControlHighlighter.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

#initializePassedControlHighlighter

Returns a new instance of PassedControlHighlighter.



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

def initialize

  observes :class => DSL::ControlEvaluation,
           :method => :Passed

end

Class Method Details

.IsObserverObject



35
36
37
# File 'lib/sapphire/Plugins/Highlighters/PassedControlHighlighter.rb', line 35

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
32
33
# File 'lib/sapphire/Plugins/Highlighters/PassedControlHighlighter.rb', line 13

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

  control = args[0]

  discriminator = control.found_by_type
  selector = control.found_by_value

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

  rescue
  end

end