class Scoutui::Commands::DoUntil
Attributes
drv[RW]
passed[RW]
Public Class Methods
new(driver)
click to toggle source
# File lib/scoutui/commands/clauses/do_until.rb, line 9 def initialize(driver) @drv=driver @pageElt=nil @passed=true @executed=false end
Public Instance Methods
do_until(pageElt)
click to toggle source
# File lib/scoutui/commands/clauses/do_until.rb, line 46 def do_until(pageElt) Scoutui::Logger::LogMgr.instance.debug __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?('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 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?('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 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') # 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') Scoutui::Logger::LogMgr.instance.debug __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 && !whenFailed.nil? #pageElt.has_key?('page') && pageElt['page'].has_key?('whenFailed') && pageElt['page']['whenFailed'].is_a?(Array) _whenFailed = execute(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 @passed=_rc end
execute(pageElt)
click to toggle source
# File lib/scoutui/commands/clauses/do_until.rb, line 24 def execute(pageElt) @executed=true 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
passed?()
click to toggle source
# File lib/scoutui/commands/clauses/do_until.rb, line 16 def passed? @passed end
wasExecuted?()
click to toggle source
# File lib/scoutui/commands/clauses/do_until.rb, line 20 def wasExecuted? @executed end