Class: Scoutui::Commands::ExecuteCommands

Inherits:
Command
  • Object
show all
Defined in:
lib/scoutui/commands/execute_commands.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

#execute(drv, e = nil) ⇒ Object



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
41
42
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
# File 'lib/scoutui/commands/execute_commands.rb', line 8

def execute(drv, e=nil)
  @drv=drv if !drv.nil?

  rc=false
  _locator=nil

  _req = Scoutui::Utils::TestUtils.instance.getReq()

  begin

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

    if e['page'].has_key?('commands')

      Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " [commands] => #{e['page']['commands'].class}"

      c=nil

      if e['page']['commands'].is_a?(String)

        _cmd =  Scoutui::Base::UserVars.instance.normalize(e['page']['commands'].to_s)

        Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + "  normalized(cmd) => #{_cmd}"
        c=CmdShellMgr::DSL.instance.cmd(:cmd => "execute(#{_cmd})")
      elsif e['page']['commands'].is_a?(Array)

        e['page']['commands'].each do |_cmd|

          if !_cmd.nil?
            _id = _cmd['id'].to_s
            Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " execute(#{_id})"
            c=CmdShellMgr::DSL.instance.cmd(:cmd => "execute(#{_id})", )

            if c.is_a?(CmdShellMgr::Command) && _cmd.has_key?('asserts')
              _cmd['asserts'].each do |_a|
                Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " assert => #{_a}"
              end
            end

          end

        end


      else
        puts __FILE__ + (__LINE__).to_s + " Unknown DSL cmd"
      end

      rc=c.is_a?(CmdShellMgr::Command)

    end


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

  if rc
    Scoutui::Logger::LogMgr.instance.asserts.info "Verify executeCommands passed - #{rc}"
    Testmgr::TestReport.instance.getReq(_req).testcase('click').add(rc, "Verify loadCommands command passed")
  end

  setResult(rc)
end