Class: Scoutui::Commands::MouseOver

Inherits:
Command
  • Object
show all
Defined in:
lib/scoutui/commands/mouse_over.rb

Instance Attribute Summary

Attributes inherited from Command

#bm, #cmd, #description, #drv, #enableAssert, #executed, #executed_result, #locator, #rc, #stanza

Instance Method Summary collapse

Methods inherited from Command

#assert?, #disableAssert, #disableAsserts, #enableAsserts, #executedResult, #getLocator, #initialize, #passed?, #result, #run, #setBenchmark, #setLocator, #setResult, #wasExecuted?

Constructor Details

This class inherits a constructor from Scoutui::Commands::Command

Instance Method Details

#_whenHovered(page_elt) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/scoutui/commands/mouse_over.rb', line 7

def _whenHovered(page_elt)

  if page_elt.is_a?(Hash) && page_elt.has_key?('when_hovered')
    Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " Verify #{page_elt['when_hovered']}"

    page_elt['when_hovered'].each do |_elt|

      _r = _elt.keys[0].to_s

      _pg = _elt[_r]

      #    _c = Scoutui::Commands::VerifyElement.new("verifyelement(" + _elt + ")")
      #    _c.execute(@drv)

      Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " processPageElement(#{_pg})"


      if _pg.is_a?(Array)
        _pg.each do |_pg2|
          isVisible=Scoutui::Base::Assertions.instance.isVisible(@drv, _pg2, _r)
        end
      elsif _pg.is_a?(String)
        isVisible=Scoutui::Base::Assertions.instance.isVisible(@drv, _pg, _r)
      else
        puts __FILE__ + (__LINE__).to_s + " => #{_pg}"
      end

  #       Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " IsVisible #{isVisible} - PAUSE"; gets

    end

  end

end

#execute(drv = nil) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/scoutui/commands/mouse_over.rb', line 43

def execute(drv=nil)
  _rc=false
  _req = Scoutui::Utils::TestUtils.instance.getReq()

  Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " MouseOver.execute(#{@cmd})"

  @drv=drv if !drv.nil?

  begin
    _locator = @cmd.match(/^\s*mouseover\s*\((.*)\)/)[1].to_s.strip
    _locator = Scoutui::Base::UserVars.instance.normalize(_locator)

    obj = Scoutui::Base::QBrowser.getObject(@drv, _locator, Scoutui::Commands::Utils.instance.getTimeout)

    if !obj.nil?
      @drv.action.move_to(obj).perform
      _rc=true


      page_elt = Scoutui::Utils::TestUtils.instance.getPageElement(_locator)
      Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " PageElement(#{_locator}) => #{page_elt}"
      _whenHovered(page_elt)


      #------------

      appModel = Scoutui::Utils::TestUtils.instance.getAppModel()

      triggers = appModel.itemize('visible_when', 'mouseover', _locator)
      Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " triggers => #{triggers}"

      if !(triggers.nil? || triggers.empty?)

        triggers.each do |_pageObj|
          _tObj=nil

          if !_pageObj.match(/^page\([\w\d]+\)/).nil?
  #         _tObj = Scoutui::Base::VisualTestFramework.processPageElement(@drv, 'peter', _pageObj)

            _tLocator = Scoutui::Utils::TestUtils.instance.getPageElement(_pageObj)
            _tObj = Scoutui::Base::QBrowser.getFirstObject(@drv, _tLocator['locator'])  # TODO: Avoid using getFirstObject

          else
            _tObj = Scoutui::Base::QBrowser.getFirstObject(@drv, _pageObj, Scoutui::Commands::Utils.instance.getTimeout())  # TODO: Avoid using getFirstObject
          end

          Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " HIT #{_pageObj} => #{!_tObj.nil?}"

          Scoutui::Logger::LogMgr.instance.asserts.info "Verify #{_pageObj} is visible when mouseover #{_locator} - #{!_tObj.nil?.to_s}"
          Testmgr::TestReport.instance.getReq(_req).get_child('mouseover').add(!_tObj.nil?, "Verify #{_pageObj} is visible when mouseover #{_locator}")
        end

      end

    end

  rescue => ex
    Scoutui::Logger::LogMgr.instance.warn "Error during processing: #{$!}"
    Scoutui::Logger::LogMgr.instance.warn "Backtrace:\n\t#{ex.backtrace.join("\n\t")}"
  end

  Testmgr::TestReport.instance.getReq(_req).testcase('mouseover').add(!obj.nil?, "Verify object #{_locator} to mouseover exists : #{obj.class.to_s}")
  Testmgr::TestReport.instance.getReq(_req).testcase('mousseover').add(_rc, "Verify mouseover #{_rc} performed for #{_locator}")
  setResult(_rc)



end