Class: RFormSpec::Window
Instance Attribute Summary collapse
Attributes inherited from BaseControl
#control_id, #parent_win
Instance Method Summary
collapse
-
#button(button_id) ⇒ Object
-
#click_button(btn_id) ⇒ Object
-
#close ⇒ Object
-
#exists? ⇒ Boolean
-
#focus ⇒ Object
-
#focus_control(ctrl_id) ⇒ Object
-
#get_class(name) ⇒ Object
return the class match by name.
-
#get_class_list ⇒ Object
-
#get_control_text(ctrl_id) ⇒ Object
-
#get_text ⇒ Object
-
#hide_dropdown(combo_id) ⇒ Object
-
#initialize(title, text = '', options = {:present => false, :wait_timeout => 0}) ⇒ Window
constructor
title : page title, depends autoit options, might use as substring match or exact match text: some text in window for further identifing the window options: present => true | false, already there wait_timeout: wiat for maxium seconds if not active, throw error (active: means the window becomes the active window) otherwise, inside window class, using focus_window methods.
-
#pixel_color(x, y) ⇒ Object
(also: #pixel_colour, #get_pixel_colour, #get_pixel_color)
-
#send_control_text(ctrl_id, text) ⇒ Object
-
#set_control_text(control_id, new_text) ⇒ Object
-
#show_dropdown(combo_id) ⇒ Object
-
#statusbar_text ⇒ Object
-
#to_s ⇒ Object
Methods inherited from BaseControl
#click, #is_enabled?, #is_visible?, #send_text, #set_text
Methods included from Driver
#close_window, #driver, #focus_window, #key_press, #mouse_click, #mouse_move, #open_file_dialog, #try_for, #wait_and_focus_window, #wait_for_window, #window_exists?
#connect_to_testwise, #debug, #dump_caller_stack, #notify_screenshot_location, #operation_delay
Constructor Details
#initialize(title, text = '', options = {:present => false, :wait_timeout => 0}) ⇒ Window
title : page title, depends autoit options, might use as substring match or exact match text: some text in window for further identifing the window options:
present => true | false, already there
wait_timeout: wiat for maxium seconds if not active, throw error
(active: means the window becomes the active window)
otherwise, inside window class, using focus_window methods
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
|
# File 'lib/rformspec/window.rb', line 17
def initialize(title, text = '', options = {:present => false, :wait_timeout => 0})
if title.class == Array
title.each { |a_title|
@title = a_title
@text = text if text
timeout = options[:wait_timeout]
result = driver.WinWaitActive(@title, @text, timeout)
return if result != 0
}
raise "timeout while waiting for window: #{self.to_s}"
end
@title = title
@text = text if text
timeout = options[:wait_timeout]
if options[:present]
result = driver.WinActivate(@title, @text)
raise "window not found: #{self.to_s}" if result == 0
elsif timeout && timeout.to_i > 1 then
result = driver.WinWaitActive(@title, @text, timeout)
raise "timeout while waiting for window: #{self.to_s}" if result == 0
end
end
|
Instance Attribute Details
#class_list ⇒ Object
Returns the value of attribute class_list.
7
8
9
|
# File 'lib/rformspec/window.rb', line 7
def class_list
@class_list
end
|
#text ⇒ Object
Returns the value of attribute text.
7
8
9
|
# File 'lib/rformspec/window.rb', line 7
def text
@text
end
|
#title ⇒ Object
Returns the value of attribute title.
7
8
9
|
# File 'lib/rformspec/window.rb', line 7
def title
@title
end
|
Instance Method Details
115
116
117
|
# File 'lib/rformspec/window.rb', line 115
def button(button_id)
RFormSpec::Button.new(self, button_id)
end
|
70
71
72
|
# File 'lib/rformspec/window.rb', line 70
def click_button(btn_id)
Button.new(self, btn_id).click
end
|
#close ⇒ Object
50
51
52
|
# File 'lib/rformspec/window.rb', line 50
def close
driver.WinClose(@title, @text)
end
|
#exists? ⇒ Boolean
54
55
56
|
# File 'lib/rformspec/window.rb', line 54
def exists?
driver.WinExists(@title, @text)
end
|
#focus ⇒ Object
46
47
48
|
# File 'lib/rformspec/window.rb', line 46
def focus
driver.WinActivate(@title, @text)
end
|
#focus_control(ctrl_id) ⇒ Object
86
87
88
|
# File 'lib/rformspec/window.rb', line 86
def focus_control(ctrl_id)
BaseControl.new(self, ctrl_id).focus
end
|
#get_class(name) ⇒ Object
return the class match by name
121
122
123
124
|
# File 'lib/rformspec/window.rb', line 121
def get_class(name)
@class_list = get_class_list
@class_list.select {|x| x.include?(name)}.collect{|y| y.strip}
end
|
#get_class_list ⇒ Object
62
63
64
|
# File 'lib/rformspec/window.rb', line 62
def get_class_list
driver.WinGetClassList(@title, @text)
end
|
#get_control_text(ctrl_id) ⇒ Object
94
95
96
|
# File 'lib/rformspec/window.rb', line 94
def get_control_text(ctrl_id)
BaseControl.new(self, ctrl_id).get_text
end
|
#get_text ⇒ Object
58
59
60
|
# File 'lib/rformspec/window.rb', line 58
def get_text
driver.WinGetText(@title, @text)
end
|
#hide_dropdown(combo_id) ⇒ Object
80
81
82
83
84
|
# File 'lib/rformspec/window.rb', line 80
def hide_dropdown(combo_id)
combo = ComboBox.new(self, combo_id)
combo.hide_dropdown
combo
end
|
#pixel_color(x, y) ⇒ Object
Also known as:
pixel_colour, get_pixel_colour, get_pixel_color
103
104
105
|
# File 'lib/rformspec/window.rb', line 103
def pixel_color(x,y)
driver.PixelGetColor(x,y)
end
|
#send_control_text(ctrl_id, text) ⇒ Object
90
91
92
|
# File 'lib/rformspec/window.rb', line 90
def send_control_text(ctrl_id, text)
BaseControl.new(self, ctrl_id).send_text(text)
end
|
#set_control_text(control_id, new_text) ⇒ Object
66
67
68
|
# File 'lib/rformspec/window.rb', line 66
def set_control_text(control_id, new_text)
BaseControl.new(self, control_id).set_text(new_text)
end
|
#show_dropdown(combo_id) ⇒ Object
74
75
76
77
78
|
# File 'lib/rformspec/window.rb', line 74
def show_dropdown(combo_id)
combo = ComboBox.new(self, combo_id)
combo.show_dropdown
combo
end
|
#statusbar_text ⇒ Object
99
100
101
|
# File 'lib/rformspec/window.rb', line 99
def statusbar_text
driver.StatusbarGetText(@title)
end
|
#to_s ⇒ Object
110
111
112
|
# File 'lib/rformspec/window.rb', line 110
def to_s
"Window{title => '#{@title}', text=>'#{@text}'}"
end
|