Class: Scoutui::Commands::JsAlert::ExistsAlert
- Defined in:
- lib/scoutui/commands/jsalert/action_jsalert.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 = nil) ⇒ Object
8 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 |
# File 'lib/scoutui/commands/jsalert/action_jsalert.rb', line 8 def execute(drv=nil) @drv=drv if !drv.nil? _rc=nil _alertExists=false Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " command => #{@cmd.to_s}" _action=@cmd.match(/(exist[s]*_*alert|existAlert|existsAlert|existsJsAlert|existsJsConfirm|existsJsPrompt)\s*\((.*)\)/i)[2].to_s.strip Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " ExistsAlert(#{_action})" alert=nil begin alert=@drv.switch_to.alert Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " | alert => #{alert.class.to_s}" _alertExists = alert.is_a?(Selenium::WebDriver::Alert) if _alertExists && !(_action.nil? && _action.empty?) _r = Regexp.new _action.to_s Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " _r => #{_r}" Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " _t => #{alert.text.to_s}" _rc=!alert.text.to_s.match(_r).nil? end rescue Selenium::WebDriver::Error::NoSuchAlertError alert=nil rescue Selenium::WebDriver::Error::WebDriverError # Support for phantomjs/ghostdriver per switch_to.alert() alert=nil end Testmgr::TestReport.instance.getReq('UI').testcase('expectJsAlert').add(_alertExists, "Verify JsAlert is present") if !(_action.nil? && _action.empty?) Testmgr::TestReport.instance.getReq('UI').get_child('expectJsAlert').add(_rc, "Verify JsAlert contains text #{_action}") setResult(_rc) end Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " ExistsAlert() => #{alert.class.to_s} rc:#{_rc.to_s}" end |