Class: Scoutui::Commands::SelectObject
- Defined in:
- lib/scoutui/commands/select_object.rb
Instance Attribute Summary
Attributes inherited from Command
#bm, #cmd, #description, #drv, #enableAssert, #executed, #executed_result, #locator, #rc, #stanza
Instance Method Summary collapse
Methods inherited from Command
#assert?, #disableAssert, #disableAsserts, #enableAsserts, #executedResult, #getLocator, #initialize, #passed?, #result, #run, #setBenchmark, #setLocator, #setResult, #wasExecuted?
Constructor Details
This class inherits a constructor from Scoutui::Commands::Command
Instance Method Details
#execute(drv, e = nil) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 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 |
# File 'lib/scoutui/commands/select_object.rb', line 9 def execute(drv, e=nil) _seekTime={ :start => 0, :end => 0 } Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " SelectObject.execute(#{e})" @drv=drv if !drv.nil? _req = Scoutui::Utils::TestUtils.instance.getReq() obj=nil _rc=false begin if !@cmd.match(/select\(/).nil? _xpath = @cmd.match(/^\s*select\((.*),\s*/)[1].to_s _val = @cmd.match(/^\s*select\(.*,\s*(.*)\)/)[1].to_s Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + "Process SELECT #{_val} into #{_xpath}" if Scoutui::Utils::TestUtils.instance.isDebug? if e.is_a?(Hash) && e.has_key?('page') && e['page'].has_key?('frames') Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " frames => #{e['page']['frames']}"; end _seekTime[:start]=Time.now obj = Scoutui::Base::QBrowser.findElement(@drv, _xpath, Scoutui::Commands::Utils.instance.getFrameSearch(), Scoutui::Commands::Utils.instance.getTimeout) _seekTime[:end]=Time.now if !obj.nil? && obj.tag_name.downcase.match(/(select)/) _opt = Selenium::WebDriver::Support::Select.new(obj) if _val.match(/\s*value:(.+)$/) _tVal = _val.match(/\s*value:(.+)$/)[1].to_s _opt.select_by(:value, Scoutui::Base::UserVars.instance.get(_tVal)) else _opt.select_by(:text, Scoutui::Base::UserVars.instance.get(_val)) end _rc=true # obj.send_keys(Scoutui::Base::UserVars.instance.get(_val)) else Scoutui::Logger::LogMgr.instance.warn __FILE__ + (__LINE__).to_s + " Unable to process command SELECT => #{obj.to_s}" end end rescue => ex Scoutui::Logger::LogMgr.instance.debug "Error during processing: #{$!}" Scoutui::Logger::LogMgr.instance.debug "Backtrace:\n\t#{ex.backtrace.join("\n\t")}" end Testmgr::TestReport.instance.getReq(_req).testcase('select').add(!obj.nil?, Scoutui::Base::UserVars.instance.normalize("Verify object to select exists #{_xpath} : #{obj.class.to_s}"), _seekTime[:end] - _seekTime[:start]) Testmgr::TestReport.instance.getReq(_req).testcase('select').add(_rc, Scoutui::Base::UserVars.instance.normalize("Verify selected text #{_val}")) setResult(_rc) end |