Class: Vapir::Firefox::ModalDialog
- Inherits:
-
Object
- Object
- Vapir::Firefox::ModalDialog
show all
- Includes:
- 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
Methods included from Window
#bring_to_front, #hwnd, #win_window
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
|
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 click_button(button_text, options={})
assert_exists
options=handle_options(options, :timeout => nil) anonymous_dialog_nodes=@modal_window.document.getAnonymousNodes(@modal_window.document.documentElement) || raise("Could not find anonymous nodes on which to look for buttons")
xul_buttons=[]
anonymous_dialog_nodes.to_array.select{|node| node.nodeType == 1 }.each do |node|
xul_buttons+=node.getElementsByTagName('xul:button').to_array.select do |button|
Vapir::fuzzy_match(button.label, button_text)
end
end
raise("Found #{xul_buttons.size} buttons which match #{button_text} - expected to find 1") unless xul_buttons.size==1
xul_button=xul_buttons.first
xul_button.disabled=false xul_button.click
end
|
#close ⇒ Object
65
66
67
|
# File 'lib/vapir-firefox/modal_dialog.rb', line 65
def close
@modal_window.close
end
|
#exists? ⇒ Boolean
33
34
35
36
|
# File 'lib/vapir-firefox/modal_dialog.rb', line 33
def exists?
@modal_window && @browser.firefox_socket && @browser.class.window_objects.any?{|window_object| window_object==@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_names ⇒ Object
77
78
79
|
# File 'lib/vapir-firefox/modal_dialog.rb', line 77
def mozilla_window_class_names
['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
|