Class: Scoutui::Commands::WhileDo
- Defined in:
- lib/scoutui/commands/clauses/while_do.rb
Instance Attribute Summary
Attributes inherited from Command
#bm, #cmd, #description, #drv, #enableAssert, #executed, #executed_result, #locator, #rc, #stanza
Instance Method Summary collapse
- #_process(untilList) ⇒ Object
- #execute(pageElt) ⇒ Object
-
#initialize(driver) ⇒ WhileDo
constructor
A new instance of WhileDo.
- #while_do(pageElt) ⇒ Object
Methods inherited from Command
#assert?, #disableAssert, #disableAsserts, #enableAsserts, #executedResult, #getLocator, #passed?, #result, #run, #setBenchmark, #setLocator, #setResult, #wasExecuted?
Constructor Details
#initialize(driver) ⇒ WhileDo
Returns a new instance of WhileDo.
7 8 9 10 11 12 13 14 |
# File 'lib/scoutui/commands/clauses/while_do.rb', line 7 def initialize(driver) Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " WhileDo.init()" @drv=driver @pageElt=nil @passed=true @executed_result=nil end |
Instance Method Details
#_process(untilList) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/scoutui/commands/clauses/while_do.rb', line 21 def _process(untilList) Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " _process(#{untilList})" if untilList.is_a?(Array) && untilList.size==1 && (untilList[0]==true || untilList[0]==false) return untilList[0] end rc=Scoutui::Base::VisualTestFramework::processAsserts(@drv, untilList, false) Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " _process(#{untilList}) => #{rc}" rc end |
#execute(pageElt) ⇒ Object
17 18 19 |
# File 'lib/scoutui/commands/clauses/while_do.rb', line 17 def execute(pageElt) setResult(while_do(pageElt)) end |
#while_do(pageElt) ⇒ Object
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 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 111 |
# File 'lib/scoutui/commands/clauses/while_do.rb', line 39 def while_do(pageElt) Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " do_until : #{pageElt}" thenList=nil untilList=nil whenPassed=nil whenFailed=nil _alwaystrue=false if pageElt.is_a?(Hash) && pageElt.has_key?('page') if pageElt['page'].has_key?('while') && pageElt['page'].has_key?('do') thenList=pageElt['page']['do'] whileList=pageElt['page']['while'] elsif pageElt['page'].has_key?('do') thenList=pageElt['page']['do'] end if pageElt['page'].has_key?('whenPassed') && pageElt['page']['whenPassed'].is_a?(Array) whenPassed=pageElt['page']['whenPassed'] end if pageElt['page'].has_key?('whenFailed') && pageElt['page']['whenFailed'].is_a?(Array) whenFailed=pageElt['page']['whenFailed'] end elsif pageElt.is_a?(Hash) && pageElt.has_key?('while') && pageElt.has_key?('do') thenList = pageElt['do'] whileList = pageElt['while'] if pageElt.has_key?('whenPassed') && pageElt['whenPassed'].is_a?(Array) whenPassed=pageElt['whenPassed'] end if pageElt.has_key?('whenFailed') && pageElt['whenFailed'].is_a?(Array) whenFailed=pageElt['whenFailed'] end end if thenList # !pageElt.nil? && pageElt['page'].has_key?('do') && pageElt['page'].has_key?('until') _max = 25 _i=0 _historyElts={} begin while (_i < _max) && _process(whileList) do Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " == process #{_i}. #{thenList}" rc=Scoutui::Commands.simpleCommands(@drv, thenList) Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " == returned process #{_i} => #{rc}" _i+=1 end # while() rescue => ex Scoutui::Logger::LogMgr.instance.warn __FILE__ + (__LINE__).to_s + " Error during processing: #{ex.}" Scoutui::Logger::LogMgr.instance.warn "Backtrace:\n\t#{ex.backtrace.join("\n\t")}" end end Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " ==== While Do Pause"; #STDIN.gets setResult(@passed) end |