Class: Vapir::IE::ModalDialogDocument
- Inherits:
-
Object
- Object
- Vapir::IE::ModalDialogDocument
- Includes:
- PageContainer
- Defined in:
- lib/vapir-ie/modal_dialog.rb
Constant Summary collapse
- @@iedialog_file =
(File.(File.dirname(__FILE__) + '/..') + "/vapir-ie/IEDialog/Release/IEDialog.dll").gsub('/', '\\')
Constants included from PageContainer
PageContainer::READYSTATE_COMPLETE
Instance Attribute Summary collapse
-
#containing_modal_dialog ⇒ Object
readonly
Returns the value of attribute containing_modal_dialog.
-
#document_object ⇒ Object
readonly
Returns the value of attribute document_object.
Instance Method Summary collapse
- #exists? ⇒ Boolean
- #get_unknown(*args) ⇒ Object
-
#initialize(containing_modal_dialog, options = {}) ⇒ ModalDialogDocument
constructor
A new instance of ModalDialogDocument.
- #locate!(options = {}) ⇒ Object
-
#modal_dialog(options = {}) ⇒ Object
this looks for a modal dialog on this modal dialog.
Methods included from PageContainer
#check_for_http_error, #close, #content_window_object, #execute_script, #html, #text, #wait
Methods included from Container
#handling_existence_failure, #log
Constructor Details
#initialize(containing_modal_dialog, options = {}) ⇒ ModalDialogDocument
Returns a new instance of ModalDialogDocument.
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/vapir-ie/modal_dialog.rb', line 83 def initialize(containing_modal_dialog, ={}) =(, :timeout => ModalDialog::DEFAULT_TIMEOUT, :error => true) @containing_modal_dialog=containing_modal_dialog intUnknown = nil ::Waiter.try_for([:timeout], :exception => ([:error] && "Unable to attach to Modal Window after #{[:timeout]} seconds.")) do intPointer = [0].pack("L") # will contain the int value of the IUnknown* get_unknown(@containing_modal_dialog.hwnd, intPointer) intArray = intPointer.unpack('L') intUnknown = intArray.first intUnknown > 0 end if intUnknown && intUnknown > 0 @document_object = WIN32OLE.connect_unknown(intUnknown) end end |
Instance Attribute Details
#containing_modal_dialog ⇒ Object (readonly)
Returns the value of attribute containing_modal_dialog.
99 100 101 |
# File 'lib/vapir-ie/modal_dialog.rb', line 99 def containing_modal_dialog @containing_modal_dialog end |
#document_object ⇒ Object (readonly)
Returns the value of attribute document_object.
100 101 102 |
# File 'lib/vapir-ie/modal_dialog.rb', line 100 def document_object @document_object end |
Instance Method Details
#exists? ⇒ Boolean
105 106 107 108 |
# File 'lib/vapir-ie/modal_dialog.rb', line 105 def exists? # todo/fix: will the document object change / become invalid / need to be relocated? @document_object && @containing_modal_dialog.exists? end |
#get_unknown(*args) ⇒ Object
78 79 80 81 82 |
# File 'lib/vapir-ie/modal_dialog.rb', line 78 def get_unknown(*args) require 'Win32API' @@get_unknown ||= Win32API.new(@@iedialog_file, 'GetUnknown', ['l', 'p'], 'v') @@get_unknown.call(*args) end |
#locate!(options = {}) ⇒ Object
101 102 103 |
# File 'lib/vapir-ie/modal_dialog.rb', line 101 def locate!(={}) exists? || raise(Vapir::Exception::WindowGoneException, "The modal dialog seems to have stopped existing.") end |
#modal_dialog(options = {}) ⇒ Object
this looks for a modal dialog on this modal dialog. but really it’s modal to the same browser window that this is modal to, so we will check for the modal on the browser, see if it isn’t the same as our self, and return it if so.
113 114 115 116 117 118 119 120 |
# File 'lib/vapir-ie/modal_dialog.rb', line 113 def modal_dialog(={}) ::Waiter.try_for(ModalDialog::DEFAULT_TIMEOUT, :exception => NoMatchingWindowFoundException.new("No other modal dialog was found on the browser."), :condition => proc{|md| md.hwnd != containing_modal_dialog.hwnd } ) do modal_dialog=containing_modal_dialog.browser.modal_dialog() end end |