class Scoutui::Commands::ThenClause
Attributes
drv[RW]
Public Class Methods
_execute(drv, thenList)
click to toggle source
# File lib/scoutui/commands/clauses/then_clause.rb, line 13 def self._execute(drv, thenList) thenList.each do |_subcmd| if _subcmd.is_a?(String) Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " | then => #{_subcmd}" if _subcmd.match(/^\s*press\(__TAB__\)$/) drv.action.send_keys(:tab).perform elsif _subcmd.match(/^\s*press\((__ESC__|__ESCAPE__)\)$/) drv.action.send_keys(:escape).perform elsif _subcmd.match(/^\s*press\(__HOLD_SHIFT__\)\s*$/) drv.action.key_down(:shift).perform Scoutui::Base::TestContext.instance.set(:shift_down, true) elsif _subcmd.match(/^\s*press\(__RELEASE_SHIFT__\)\s*$/) drv.action.key_up(:shift).perform Scoutui::Base::TestContext.instance.set(:shift_down, false) elsif _subcmd.match(/^\s*press\(__HOLD_COMMAND__\)$/) drv.action.key_down(:command).perform Scoutui::Base::TestContext.instance.set(:command_down, true) elsif _subcmd.match(/^\s*press\(__RELEASE_COMMAND__\)$/) drv.action.key_up(:command).perform Scoutui::Base::TestContext.instance.set(:command_down, false) elsif _subcmd.match(/^\s*press\(__CONTROL__\)$/) drv.driver.action.key_down(:control).perform drv.action.key_up(:control).perform # Check for list of elements to click elsif _subcmd.match(/^\s*press\(__DOWN__\)$/) Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " Press down" drv.action.send_keys(:arrow_down).perform elsif _subcmd.match(/^\s*press\(__UP__\)$/) drv.action.send_keys(:arrow_up).perform elsif _subcmd.match(/^\s*press\(__ENTER__\)\s*$/) drv.action.send_keys(:enter).perform elsif _subcmd.match(/^\s*focused\.[Hh]ighlight\s*$/i) _activeElt = drv.switch_to.active_element if !_activeElt.nil? Scoutui::Base::QBrowser.highlight(drv, _activeElt) end elsif _subcmd.match(/^\s*click\((.*)\)\s*$/) # Click on the locator _c = Scoutui::Commands::ClickObject.new(_subcmd) _c.run(driver: drv) elsif _subcmd.match(/^\s*press\(__SPACE__\)\s*$/) drv.action.send_keys(:space).perform elsif Scoutui::Commands::Utils.instance.isMouseOver?(_subcmd) _cmd='MouseOver' _c = Scoutui::Commands::MouseOver.new(_subcmd) _c.execute(drv) elsif Scoutui::Commands::Utils.instance.isPause?(_subcmd) _cmd='pause' _c = Scoutui::Commands::Pause.new(nil) _c.execute(); elsif _subcmd.match(/^\s*press\((.*)\)\s*$/) _locator = _subcmd.match(/^\s*press\((.*)\)\s*$/)[1].to_s _locator = Scoutui::Base::UserVars.instance.normalize(_locator) obj = Scoutui::Base::QBrowser.getElement(drv, _locator, Scoutui::Commands::Utils.instance.getFrameSearch(), Scoutui::Commands::Utils.instance.getTimeout) obj.click end end end end
new(driver)
click to toggle source
# File lib/scoutui/commands/clauses/then_clause.rb, line 8 def initialize(driver) @drv=driver @pageElt=nil end
Public Instance Methods
execute(pageElt)
click to toggle source
# File lib/scoutui/commands/clauses/then_clause.rb, line 100 def execute(pageElt) rc=true thenList=nil if !pageElt.nil? && pageElt.is_a?(Hash) && pageElt.has_key?('page') && pageElt['page'].has_key?('then') @pageElt=pageElt thenList=pageElt['page']['then'] elsif pageElt.is_a?(Array) thenList=pageElt end rc=Scoutui::Commands::ThenClause._execute(@drv, pageElt['page']['then']) if thenList rc end
execute_until(pageElt)
click to toggle source
# File lib/scoutui/commands/clauses/then_clause.rb, line 119 def execute_until(pageElt) if !pageElt.nil? && pageElt['page'].has_key?('then') && pageElt['page'].has_key?('until') thenList=pageElt['page']['then'] _loop=true _i=0 _historyElts={} _bUntil=false while _loop && !_bUntil do if thenList.is_a?(Array) thenClause = Scoutui::Commands::ThenClause.new(@drv) thenClause.execute(pageElt) _activeElt = @drv.switch_to.active_element Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " ActiveElt => #{_activeElt.text}" if _historyElts.size > 0 && _historyElts.has_key?(_activeElt) Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + "****** WRAPPED ******"; #STDIN.gets _loop=false else _historyElts[_activeElt]=true end end if _loop && !pageElt.nil? && pageElt['page'].has_key?('until') _expected=Scoutui::Base::VisualTestFramework::processAsserts(@drv, pageElt['page']['until'], false) Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " ==> until : #{_expected}" _loop=!_expected if _expected _bUntil=true end elsif !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 elsif !pageElt.nil? && pageElt['page'].has_key?('then') _rc=execute(pageElt) else _rc=true end _rc end