lib/scoutui/commands/utils.rb in scoutui-2.0.5.3 vs lib/scoutui/commands/utils.rb in scoutui-2.0.5.4

- old
+ new

@@ -14,10 +14,11 @@ def initialize @command_list=['pause', 'assignvar', 'assignments', + 'doUntil', 'existsAlert', 'clickJsAlert', 'dumpvars', 'fillform', 'frame', @@ -38,11 +39,12 @@ 'select_window', 'sleep', 'uploadfiles', 'verifyelt', 'verifyelement', - 'verifyform'] + 'verifyform', + 'whileDo'] @totalCommands={} @timeout=30 @command_list.each do |c| @totalCommands[c]=0 end @@ -226,123 +228,135 @@ def getTimeout() @timeout.to_i end + def isDoUntil?(_action) + _action.is_a?(Hash) && _action.has_key?('do') && !_action.has_key?('while') + end + + def isWhileDo?(_action) + _action.is_a?(Hash) && _action.has_key?('while') && _action.has_key?('do') + end + def isAssignments?(_action) - !_action.match(/^\s*(assignments)\s*$/).nil? + _action.is_a?(String) && !_action.match(/^\s*(assignments)\s*$/).nil? end def isAssignVar?(_action) - !_action.match(/assign\(([\w]+)\s*\,(.*)\)\s*$/i).nil? + _action.is_a?(String) && !_action.match(/assign\(([\w]+)\s*\,(.*)\)\s*$/i).nil? end def isSelectWindow?(_action) - !_action.match(/^\s*select_window/i).nil? + _action.is_a?(String) && !_action.match(/^\s*select_window/i).nil? end def isExistsAlert?(_action) - !_action.match(/(exist[s]*_*alert|existAlert|existsAlert|existsJsAlert|existsJsConfirm|existsJsPrompt)\(/i).nil? + _action.is_a?(String) && !_action.match(/(exist[s]*_*alert|existAlert|existsAlert|existsJsAlert|existsJsConfirm|existsJsPrompt)\(/i).nil? end def isFrame?(_action) - _action.match(/^\s*(frame|switchframe|switch_frame)\s*\(/i) + _action.is_a?(String) && _action.match(/^\s*(frame|switchframe|switch_frame)\s*\(/i) end def isHighlight?(_action) - _action.match(/^\s*(highlight)/i) + _action.is_a?(String) && _action.match(/^\s*(highlight)/i) end def isVerifyElt?(_action) - !_action.match(/(verifyelt|verifyelement)\(/i).nil? + _action.is_a?(String) && !_action.match(/(verifyelt|verifyelement)\(/i).nil? end def isClick?(_action) - !_action.match(/click\(/i).nil? + _action.is_a?(String) && !_action.match(/click\(/i).nil? end def isGetAlert?(_action) - !_action.match(/(get_*alert|clickjsconfirm|clickjsprompt|clickjsalert)/i).nil? + _action.is_a?(String) && !_action.match(/(get_*alert|clickjsconfirm|clickjsprompt|clickjsalert)/i).nil? end def isFillForm?(_action) - !_action.match(/fillform\(/i).nil? + _action.is_a?(String) && !_action.match(/fillform\(/i).nil? end def isConnect?(_action) - !_action.match(/^\s*connect\s*$/i).nil? + _action.is_a?(String) && !_action.match(/^\s*connect\s*$/i).nil? end def isDumpVars?(_action) - !_action.match(/^\s*dumpvars\s*$/i).nil? + _action.is_a?(String) && !_action.match(/^\s*dumpvars\s*$/i).nil? end def isLoadDB?(_action) - !_action.match(/^\s*loaddb\s*$/i).nil? + _action.is_a?(String) && !_action.match(/^\s*loaddb\s*$/i).nil? end def isExecuteCommands?(_action) - !_action.match(/^\s*executecommand[s]*\s*$/i).nil? + _action.is_a?(String) && !_action.match(/^\s*executecommand[s]*\s*$/i).nil? end def isDefineCommands?(_action) - !_action.match(/^\s*definecommand[s]*\s*$/i).nil? + _action.is_a?(String) && !_action.match(/^\s*definecommand[s]*\s*$/i).nil? end def isLoadData?(_action) - !_action.match(/^\s*loaddata\s*$/i).nil? + _action.is_a?(String) && !_action.match(/^\s*loaddata\s*$/i).nil? end def isLoadJs?(_action) - !_action.match(/^\s*loadjs\s*$/i).nil? + _action.is_a?(String) && !_action.match(/^\s*loadjs\s*$/i).nil? end def isLoadRequirements?(_action) - !_action.match(/^\s*loadrequirements\s*$/i).nil? + _action.is_a?(String) && !_action.match(/^\s*loadrequirements\s*$/i).nil? end def isMouseOver?(_action) - !_action.match(/mouseover\(/).nil? + _action.is_a?(String) && !_action.match(/mouseover\(/).nil? end def isType?(_action) - !_action.match(/type[\!]*\(/).nil? + _action.is_a?(String) && !_action.match(/type[\!]*\(/).nil? end def isSubmitForm?(_action) - !_action.match(/submitform\(/).nil? + _action.is_a?(String) && !_action.match(/submitform\(/).nil? end def isVerifyForm?(_action) - !_action.match(/verifyform\(/).nil? + _action.is_a?(String) && !_action.match(/verifyform\(/).nil? end def isPause?(_action) - !_action.match(/pause/).nil? + _action.is_a?(String) && !_action.match(/pause/).nil? end def isSelect?(_action) - !_action.nil? && _action.match(/^\s*select\s*\(/i) + !_action.nil? && _action.is_a?(String) && _action.match(/^\s*select\s*\(/i) end def isSleep?(_action) - !_action.nil? && _action.match(/^\s*sleep\s*\(\s*\d+\s*\)\s*$/i) + !_action.nil? && _action.is_a?(String) && _action.match(/^\s*sleep\s*\(\s*\d+\s*\)\s*$/i) end def isUploadFiles?(_action) - !_action.nil? && _action.match(/^\s*uploadfiles\s*$/i) + !_action.nil? && _action.is_a?(String) && _action.match(/^\s*uploadfiles\s*$/i) end def isNavigate?(_action) - !_action.nil? && _action.match(/(navigate|url)\(/i) + !_action.nil? && _action.is_a?(String) && _action.match(/(navigate|url)\(/i) end def isValid?(cmd) rc=true - if isPause?(cmd) + if isDoUntil?(cmd) + @totalCommands['doUntil']+=1 + elsif isWhileDo?(cmd) + @totalCommands['whileDo']+=1 + elsif isPause?(cmd) @totalCommands['pause']+=1 elsif isAssignVar?(cmd) @totalCommands['assignvar']+=1 elsif isAssignments?(cmd) @totalCommands['assignments']+=1