Class: Sapphire::Plugins::FailedControlHighlighter

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

#initializeFailedControlHighlighter

Returns a new instance of FailedControlHighlighter.



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

def initialize

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

end

Class Method Details

.IsObserverObject



34
35
36
# File 'lib/sapphire/Plugins/Highlighters/FailedControlHighlighter.rb', line 34

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
# File 'lib/sapphire/Plugins/Highlighters/FailedControlHighlighter.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 = '#FF0000'; ")
    elsif (discriminator == :name )
      $driver.ExecuteScript("document.getElementByName('#{selector}').style.backgroundColor = '#FF0000'; ")
    elsif (discriminator == :xpath)
      $driver.ExecuteScript("document.evaluate( '#{selector}', document, null, XPathResult.ANY_TYPE, null ).iterateNext().style.backgroundColor = '#FF0000'; ")
    end

  rescue
  end

end