Class: Scoutui::Commands::DoUntil
- Inherits:
-
Object
- Object
- Scoutui::Commands::DoUntil
- Defined in:
- lib/scoutui/commands/clauses/do_until.rb
Instance Attribute Summary collapse
-
#drv ⇒ Object
Returns the value of attribute drv.
Instance Method Summary collapse
- #do_until(pageElt) ⇒ Object
- #execute(pageElt) ⇒ Object
-
#initialize(driver) ⇒ DoUntil
constructor
A new instance of DoUntil.
Constructor Details
#initialize(driver) ⇒ DoUntil
Returns a new instance of DoUntil.
8 9 10 11 |
# File 'lib/scoutui/commands/clauses/do_until.rb', line 8 def initialize(driver) @drv=driver @pageElt=nil end |
Instance Attribute Details
#drv ⇒ Object
Returns the value of attribute drv.
6 7 8 |
# File 'lib/scoutui/commands/clauses/do_until.rb', line 6 def drv @drv end |
Instance Method Details
#do_until(pageElt) ⇒ Object
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 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 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/scoutui/commands/clauses/do_until.rb', line 35 def do_until(pageElt) puts __FILE__ + (__LINE__).to_s + " do_until : #{pageElt}" thenList=nil untilList=nil whenPassed=nil _alwaystrue=false if pageElt.is_a?(Hash) && pageElt.has_key?('page') if pageElt['page'].has_key?('do') && pageElt['page'].has_key?('until') thenList=pageElt['page']['do'] untilList=pageElt['page']['until'] 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 elsif pageElt.is_a?(Hash) && pageElt.has_key?('do') && pageElt.has_key?('until') thenList = pageElt['do'] untilList = pageElt['until'] if pageElt.has_key?('whenPassed') && pageElt['whenPassed'].is_a?(Array) whenPassed=pageElt['whenPassed'] end end if thenList # !pageElt.nil? && pageElt['page'].has_key?('do') && pageElt['page'].has_key?('until') # thenList=pageElt['page']['do'] _loop=true _i=0 _historyElts={} _bUntil=false while _loop && !_bUntil do if thenList.is_a?(Array) # thenClause = Scoutui::Commands::DoUntil.new(@drv) # thenClause.execute(pageElt) execute(pageElt) # Get the active (focused) element _activeElt = @drv.switch_to.active_element if _activeElt.is_a?(Selenium::WebDriver::Element) Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " ActiveElt => #{_activeElt.tag_name} : #{_activeElt.text}" # Check if Tabbed element is displayed. if !_activeElt.displayed? Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " ** Tabbled-on element is NOT displayed" end end if _historyElts.size > 0 && _historyElts.has_key?(_activeElt) Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + "****** WRAPPED (#{_historyElts.size}) #{_historyElts.has_key?(_activeElt)} ******" _loop=false else _historyElts[_activeElt]=true end end if _loop && untilList # !pageElt.nil? && pageElt['page'].has_key?('until') puts __FILE__ + (__LINE__).to_s + " untilList => #{untilList.class}, #{untilList.size}, #{untilList[0]}" if untilList.is_a?(Array) && untilList.size==1 && untilList[0]==true _expected=false _alwaystrue=true elsif untilList.is_a?(Array) && untilList.size==1 && untilList[0]==false _loop=false _bUntil=true _alwaystrue=true else _expected=Scoutui::Base::VisualTestFramework::processAsserts(@drv, untilList, false) end Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " ==> until : #{_expected}"; #STDIN.gets _loop=!_expected if _expected _bUntil=true end elsif untilList.nil? # !pageElt['page'].has_key?('until') _loop=false _bUntil=true end _i+=1 if !_bUntil && _i > 75 _loop=false Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " ** BREAK OUT **"; #STDIN.gets end end # while() _rc=_bUntil if _bUntil && whenPassed.is_a?(Array) #pageElt['page'].has_key?('whenPassed') && pageElt['page']['whenPassed'].is_a?(Array) Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " ==== whenPassed #{_rc} =======" _whenPassed = execute(whenPassed) Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " ===== end.whenPassed : #{_whenPassed} =====" elsif !_bUntil && pageElt.has_key?('page') && pageElt['page'].has_key?('whenFailed') && pageElt['page']['whenFailed'].is_a?(Array) _whenFailed = execute(pageElt['page']['whenFailed']) elsif _alwaystrue _rc=true end elsif thenList # !pageElt.nil? && pageElt.has_key?('page') && pageElt['page'].has_key?('do') #_rc=execute(pageElt) _rc=execute(thenList) else _rc=true end _rc end |
#execute(pageElt) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/scoutui/commands/clauses/do_until.rb', line 14 def execute(pageElt) rc=true cmdList=nil if !pageElt.nil? && pageElt.is_a?(Hash) && pageElt.has_key?('page') && pageElt['page'].has_key?('do') @pageElt=pageElt cmdList=pageElt['page']['do'] elsif !pageElt.nil? && pageElt.is_a?(Hash) && pageElt.has_key?('do') cmdList=pageElt['do'] elsif pageElt.is_a?(Array) cmdList=pageElt end rc=Scoutui::Commands.simpleCommands(@drv, cmdList) if cmdList rc end |