Class: Vapir::Firefox::ModalDialog
- Includes:
- Firefox::Window, ModalDialog
- Defined in:
- lib/vapir-firefox/modal_dialog.rb
Overview
represents a window which is modal to a parent window
Instance Method Summary collapse
- #browser_window_object ⇒ Object
- #click_button(button_text, options = {}) ⇒ Object
- #close ⇒ Object
- #document ⇒ Object
- #exists? ⇒ Boolean
- #locate ⇒ Object
- #mozilla_window_class_name ⇒ Object
- #set_text_field(value) ⇒ Object
- #text ⇒ Object
Instance Method Details
#browser_window_object ⇒ Object
73 74 75 76 |
# File 'lib/vapir-firefox/modal_dialog.rb', line 73 def browser_window_object assert_exists modal_window end |
#click_button(button_text, options = {}) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/vapir-firefox/modal_dialog.rb', line 48 def (, ={}) assert_exists =(, :timeout => nil) # we don't actually use timeout here. maybe should error on it? # raise if no anonymous nodes are found (this is where the buttons are) anonymous_dialog_nodes=@modal_window.document.getAnonymousNodes(@modal_window.document.documentElement) || raise("Could not find anonymous nodes on which to look for buttons") =[] anonymous_dialog_nodes.to_array.each do |node| +=node.getElementsByTagName('xul:button').to_array.select do || Vapir::fuzzy_match(.label, ) end end raise("Found #{.size} buttons which match #{} - expected to find 1") unless .size==1 =.first .disabled=false # get around firefox's stupid thing where the default button is disabled for a few seconds or something, god knows why .click end |
#close ⇒ Object
65 66 67 |
# File 'lib/vapir-firefox/modal_dialog.rb', line 65 def close @modal_window.close end |
#document ⇒ Object
69 70 71 72 |
# File 'lib/vapir-firefox/modal_dialog.rb', line 69 def document assert_exists Firefox::ModalDialogDocument.new(self) end |
#exists? ⇒ Boolean
33 34 35 36 |
# File 'lib/vapir-firefox/modal_dialog.rb', line 33 def exists? # jssh_socket may be nil if the window has closed @modal_window && @browser.jssh_socket && @browser.jssh_socket.object('getWindows()').to_js_array.include(@modal_window) end |
#locate ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/vapir-firefox/modal_dialog.rb', line 10 def locate candidates=[] Vapir::Firefox.each_window_object do |win| opener=win.attr(:opener) opener=nil unless opener.type=='object' content=win.attr(:content) if content.type=='object' content_opener=content.attr(:opener) content_opener=nil unless content_opener.type=='object' end if [@browser.browser_window_object, @browser.content_window_object].any?{|_w| [opener, content_opener].compact.include?(_w) } candidates << win end end if candidates.size==0 nil elsif candidates.size==1 @modal_window=candidates.first else raise "Multiple windows found which this is a parent of - cannot determine which is the expected modal dialog" end end |
#mozilla_window_class_name ⇒ Object
77 78 79 |
# File 'lib/vapir-firefox/modal_dialog.rb', line 77 def mozilla_window_class_name 'MozillaDialogClass' end |
#set_text_field(value) ⇒ Object
43 44 45 46 |
# File 'lib/vapir-firefox/modal_dialog.rb', line 43 def set_text_field(value) assert_exists raise NotImplementedError end |
#text ⇒ Object
38 39 40 41 |
# File 'lib/vapir-firefox/modal_dialog.rb', line 38 def text assert_exists @modal_window.document.documentElement.textContent end |