Class: Vapir::Firefox::ModalDialogDocument

Inherits:
Object
  • Object
show all
Includes:
ModalDialogContainer, PageContainer
Defined in:
lib/vapir-firefox/modal_dialog.rb

Overview

this represents a document contained within a modal dialog (a Firefox::ModalDialog) which was opened, generally, via a call to window.showModalDialog.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ModalDialogContainer

#modal_dialog, #modal_dialog!

Methods included from PageContainer

#execute_script, #outer_html, #text

Methods included from Container

#element_by_xpath, #element_object_by_xpath, #element_objects_by_xpath, #elements_by_xpath, #extra_for_contained, #innermost_by_node, #innermost_matching_visible_text, #visible_text_nodes

Constructor Details

#initialize(containing_modal_dialog, options = {}) ⇒ ModalDialogDocument

Returns a new instance of ModalDialogDocument.



108
109
110
111
112
113
114
# File 'lib/vapir-firefox/modal_dialog.rb', line 108

def initialize(containing_modal_dialog, options={})
  options=handle_options(options, :timeout => ModalDialog::DEFAULT_TIMEOUT, :error => true)
  @firefox_socket=containing_modal_dialog.browser.firefox_socket
  @browser_object=containing_modal_dialog.modal_window.getBrowser

  @containing_modal_dialog=containing_modal_dialog
end

Instance Attribute Details

#browser_objectObject (readonly)

Returns the value of attribute browser_object.



116
117
118
# File 'lib/vapir-firefox/modal_dialog.rb', line 116

def browser_object
  @browser_object
end

#containing_modal_dialogObject (readonly)

Returns the value of attribute containing_modal_dialog.



115
116
117
# File 'lib/vapir-firefox/modal_dialog.rb', line 115

def containing_modal_dialog
  @containing_modal_dialog
end

#firefox_socketObject (readonly)

Returns the value of attribute firefox_socket.



143
144
145
# File 'lib/vapir-firefox/modal_dialog.rb', line 143

def firefox_socket
  @firefox_socket
end

Instance Method Details

#browser_window_objectObject



124
125
126
# File 'lib/vapir-firefox/modal_dialog.rb', line 124

def browser_window_object
  containing_modal_dialog.modal_window
end

#content_window_objectObject



121
122
123
# File 'lib/vapir-firefox/modal_dialog.rb', line 121

def content_window_object
  browser_object.contentWindow
end

#document_objectObject



118
119
120
# File 'lib/vapir-firefox/modal_dialog.rb', line 118

def document_object
  browser_object.contentDocument
end

#exists?Boolean

Returns:

  • (Boolean)


131
132
133
134
# File 'lib/vapir-firefox/modal_dialog.rb', line 131

def exists?
  # todo/fix: will the document object change / become invalid / need to be relocated? 
  @containing_modal_dialog.exists? && document_object
end

#locate!(options = {}) ⇒ Object



127
128
129
# File 'lib/vapir-firefox/modal_dialog.rb', line 127

def locate!(options={})
  exists? || raise(Vapir::Exception::WindowGoneException, "The modal dialog seems to have stopped existing.")
end

#wait(options = nil) ⇒ Object



136
137
138
139
140
141
# File 'lib/vapir-firefox/modal_dialog.rb', line 136

def wait(options=nil)
  return unless config.wait
  ::Waiter.try_for(config.wait_timeout) do
    !browser_object.webProgress.isLoadingDocument
  end
end