lib/scoutui/commands/utils.rb in scoutui-2.0.1 vs lib/scoutui/commands/utils.rb in scoutui-2.0.2

- old
+ new

@@ -7,42 +7,76 @@ class Utils include Singleton attr_accessor :totalCommands attr_accessor :timeout + attr_accessor :hwnds def initialize @command_list=['pause', 'existsAlert', + 'clickJsAlert', 'fillform', 'submitform', 'type', 'click', 'mouseover', 'navigate', 'select', + 'select_window', 'verifyelt', 'verifyelement', 'verifyform'] @totalCommands={} @timeout=30 @command_list.each do |c| @totalCommands[c]=0 end + + @hwnds = { :current => nil, :previous => nil, :handles => [] } end - def resetTimeout() - setTimeout(30) + + def isCSS(_locator) + rc=nil + + if _locator.match(/^css\=/i) + rc = _locator.match(/\s*(css\=.*)/i)[1].to_s.strip + elsif _locator.match(/^#/i) + rc=_locator.strip + end + + rc end + + def setCurrentWindow(_w) + if @hwnds[:previous].nil? + @hwnds[:previous]=_w + else + @hwnds[:previous]=@hwnds[:current] + end + + @hwnds[:current]=_w + end + + def resetTimeout(t=30) + setTimeout(t) + end + def setTimeout(_t) - @timeout=_t + @timeout=_t.to_i end def getTimeout() - @timeout + @timeout.to_i end + def isSelectWindow?(_action) + Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " isSelectWindow?(#{_action})" + !_action.match(/select_window/i).nil? + end + def isExistsAlert?(_action) !_action.match(/(exist[s]*_*alert|existAlert|existsAlert|existsJsAlert|existsJsConfirm|existsJsPrompt)\(/i).nil? end def isVerifyElt?(_action) @@ -64,11 +98,11 @@ def isMouseOver?(_action) !_action.match(/mouseover\(/).nil? end def isType?(_action) - !_action.match(/type\(/).nil? + !_action.match(/type[\!]*\(/).nil? end def isSubmitForm?(_action) !_action.match(/submitform\(/).nil? end @@ -95,10 +129,12 @@ if isPause?(cmd) @totalCommands['pause']+=1 elsif isExistsAlert?(cmd) @totalCommands['existsAlert']+=1 + elsif isGetAlert?(cmd) + @totalCommands['clickJsAlert']+=1 elsif isVerifyElt?(cmd) @totalCommands['verifyelt']+=1 elsif isVerifyForm?(cmd) @totalCommands['verifyform']+=1 elsif isFillForm?(cmd) @@ -113,9 +149,11 @@ @totalCommands['mouseover']+=1 elsif isSelect?(cmd) @totalCommands['select']+=1 elsif isNavigate?(cmd) @totalCommands['navigate']+=1 + elsif isSelectWindow?(cmd) + @totalCommands['select_window']+=1 else rc=false end rc