operawatir 0.3-jruby → 0.3.2-jruby
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +6 -2
- data/LICENSE +1 -1
- data/Rakefile +7 -8
- data/VERSION +1 -1
- data/bin/desktopwatir +3 -0
- data/bin/operawatir +2 -2
- data/lib/operadriver/webdriver-opera.jar +0 -0
- data/lib/operawatir.rb +14 -8
- data/lib/operawatir/browser.rb +49 -38
- data/lib/operawatir/compat/collection.rb +6 -0
- data/lib/operawatir/compat/element.rb +5 -2
- data/lib/operawatir/compat/element_finders.rb +19 -0
- data/lib/operawatir/desktop-waiter.rb +144 -0
- data/lib/operawatir/desktop_browser.rb +506 -0
- data/lib/operawatir/desktop_common.rb +111 -0
- data/lib/operawatir/desktop_container.rb +252 -0
- data/lib/operawatir/desktop_enums.rb +42 -0
- data/lib/operawatir/desktop_exceptions.rb +16 -0
- data/lib/operawatir/element.rb +6 -6
- data/lib/operawatir/exceptions.rb +3 -0
- data/lib/operawatir/keys.rb +116 -0
- data/lib/operawatir/platform.rb +59 -0
- data/lib/operawatir/quickwidgets.rb +3 -0
- data/lib/operawatir/quickwidgets/quick_addressfield.rb +23 -0
- data/lib/operawatir/quickwidgets/quick_button.rb +151 -0
- data/lib/operawatir/quickwidgets/quick_checkbox.rb +58 -0
- data/lib/operawatir/quickwidgets/quick_dialogtab.rb +23 -0
- data/lib/operawatir/quickwidgets/quick_dropdown.rb +27 -0
- data/lib/operawatir/quickwidgets/quick_editfield.rb +115 -0
- data/lib/operawatir/quickwidgets/quick_label.rb +12 -0
- data/lib/operawatir/quickwidgets/quick_radiobutton.rb +11 -0
- data/lib/operawatir/quickwidgets/quick_searchfield.rb +25 -0
- data/lib/operawatir/quickwidgets/quick_tab.rb +66 -0
- data/lib/operawatir/quickwidgets/quick_thumbnail.rb +26 -0
- data/lib/operawatir/quickwidgets/quick_toolbar.rb +11 -0
- data/lib/operawatir/quickwidgets/quick_treeitem.rb +157 -0
- data/lib/operawatir/quickwidgets/quick_treeview.rb +27 -0
- data/lib/operawatir/quickwidgets/quick_widget.rb +369 -0
- data/lib/operawatir/quickwidgets/quick_window.rb +150 -0
- data/lib/operawatir/selector.rb +1 -1
- data/lib/operawatir/version.rb +0 -1
- data/lib/operawatir/window.rb +9 -0
- data/operawatir.gemspec +382 -0
- data/spec/new_watirspec/browser_spec.rb +279 -0
- data/spec/new_watirspec/clipboard_spec.rb +79 -0
- data/spec/new_watirspec/collection_spec.rb +387 -0
- data/spec/new_watirspec/element_spec.rb +456 -0
- data/spec/new_watirspec/guards.rb +39 -0
- data/spec/new_watirspec/keys_spec.rb +206 -0
- data/spec/new_watirspec/server.rb +91 -0
- data/spec/new_watirspec/watirspec_helper.rb +62 -0
- data/spec/new_watirspec/window_spec.rb +370 -0
- data/utils/launchers/launcher-mac +0 -0
- metadata +191 -28
- data/.gitmodules +0 -3
@@ -0,0 +1,506 @@
|
|
1
|
+
module OperaWatir
|
2
|
+
class DesktopBrowser < Browser
|
3
|
+
include DesktopContainer
|
4
|
+
include DesktopCommon
|
5
|
+
|
6
|
+
#@private
|
7
|
+
LoadActions = ["Open url in new page", "Open url in current page", "Open url in background page",
|
8
|
+
"Open url in new window"]
|
9
|
+
|
10
|
+
# @private
|
11
|
+
def initialize (executable_location = nil, *arguments)
|
12
|
+
if executable_location.nil? or executable_location.length == 0
|
13
|
+
@driver = OperaDesktopDriver.new
|
14
|
+
else
|
15
|
+
@driver = OperaDesktopDriver.new(executable_location, arguments.to_java(:String))
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# @private
|
20
|
+
# Hack overload to allow for timing of the OnLoaded event that can cause
|
21
|
+
# dialogs to autoclose in Dialog.cpp when then OnUrlChanged is fired
|
22
|
+
# after a dialog is opened
|
23
|
+
def goto(url = "")
|
24
|
+
super
|
25
|
+
sleep(1)
|
26
|
+
end
|
27
|
+
|
28
|
+
######################################################################
|
29
|
+
# Quits the driver without exiting Opera
|
30
|
+
#
|
31
|
+
def quit_driver()
|
32
|
+
@driver.shutdown
|
33
|
+
end
|
34
|
+
|
35
|
+
######################################################################
|
36
|
+
# Executes the action given by action_name, and waits for
|
37
|
+
# the window with window name win_name to be shown
|
38
|
+
#
|
39
|
+
# @example
|
40
|
+
# browser.open_window_with_action("New Preferences Dialog", "Show preferences")
|
41
|
+
# browser.open_window_with_action("New Preferences Dialog", "Show preferences", "1")
|
42
|
+
#
|
43
|
+
# @param [String] win_name name of the window that will be opened (Pass a blank string for any window)
|
44
|
+
# @param [String] action_name name of the action to execute to open the window
|
45
|
+
# the action cannot be a load action, see LoadActions
|
46
|
+
# @param [String] param optional parameter(s) to be supplied with the Opera action.
|
47
|
+
#
|
48
|
+
# @return [int] Window ID of the window shown or 0 if no window is shown
|
49
|
+
def open_window_with_action(win_name, action_name, *params)
|
50
|
+
if LoadActions.include?(action_name) then
|
51
|
+
raise(DesktopExceptions::UnsupportedActionException, "Action #{action_name} not supported")
|
52
|
+
end
|
53
|
+
|
54
|
+
wait_start
|
55
|
+
opera_desktop_action(action_name, *params)
|
56
|
+
wait_for_window_shown(win_name)
|
57
|
+
end
|
58
|
+
|
59
|
+
alias_method :open_dialog_with_action, :open_window_with_action
|
60
|
+
|
61
|
+
######################################################################
|
62
|
+
# Executes the action given by action_name, and waits for
|
63
|
+
# the window with window name win_name to be loaded
|
64
|
+
#
|
65
|
+
# @example
|
66
|
+
# browser.load_window_with_action("Document Window", "Open url in new page", "http://elg.no")
|
67
|
+
#
|
68
|
+
# @param [String] win_name name of the window that will be opened (Pass a blank string for any window)
|
69
|
+
# @param [String] action_name name of the action to execute to open the window
|
70
|
+
# the action has to be one of those in LoadActions
|
71
|
+
# @param [String] param optional parameter(s) to be supplied with the Opera action.
|
72
|
+
#
|
73
|
+
# @return [int] Window ID of the window shown or 0 if no window is shown
|
74
|
+
def load_window_with_action(win_name, action_name, *params)
|
75
|
+
if LoadActions.include?(action_name)
|
76
|
+
wait_start
|
77
|
+
opera_desktop_action(action_name, *params)
|
78
|
+
wait_for_window_loaded(win_name)
|
79
|
+
else
|
80
|
+
raise(DesktopExceptions::UnsupportedActionException, "Action #{action_name} not supported")
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
######################################################################
|
85
|
+
# Presses the key, with optional modifiers, and waits for
|
86
|
+
# the window with window name win_name to be shown
|
87
|
+
#
|
88
|
+
# @example
|
89
|
+
# browser.open_window_with_key_press("New Preferences Dialog", "F12")
|
90
|
+
# browser.open_window_with_key_press("New Preferences Dialog", "F12", :ctrl, :shift)
|
91
|
+
#
|
92
|
+
# @param [String] win_name name of the window that will be opened (Pass a blank string for any window)
|
93
|
+
# @param [String] key key to press (e.g. "a" or "backspace")
|
94
|
+
# @param [Symbol] modifiers optional modifier(s) to hold down while pressing the key (e.g. :shift, :ctrl, :alt, :meta)
|
95
|
+
#
|
96
|
+
# @return [int] Window ID of the window shown or 0 if no window is shown
|
97
|
+
#
|
98
|
+
def open_window_with_key_press(win_name, key, *modifiers)
|
99
|
+
wait_start
|
100
|
+
key_press_direct(key, *modifiers)
|
101
|
+
wait_for_window_shown(win_name)
|
102
|
+
end
|
103
|
+
|
104
|
+
alias_method :open_dialog_with_key_press, :open_window_with_key_press
|
105
|
+
|
106
|
+
######################################################################
|
107
|
+
# Clicks the key and modifiers and waits for a new tab to be activated
|
108
|
+
#
|
109
|
+
# @param [String] key key to press (e.g. "a" or "backspace")
|
110
|
+
# @param [Symbol] modifiers optional modifier(s) to hold down while pressing
|
111
|
+
# the key (e.g. :shift, :ctrl, :alt, :meta)
|
112
|
+
#
|
113
|
+
# @return [int] Window ID of the document window (tab) that is activated, or 0 if no tab
|
114
|
+
# is being activated
|
115
|
+
#
|
116
|
+
def activate_tab_with_key_press(key, *modifiers)
|
117
|
+
wait_start
|
118
|
+
# TODO: FIXME. key_down and up are not yet implemented on mac and windows
|
119
|
+
if linux?
|
120
|
+
key_down(key,*modifiers)
|
121
|
+
key_up(key, *modifiers)
|
122
|
+
else
|
123
|
+
key_press_direct(key, *modifiers)
|
124
|
+
end
|
125
|
+
wait_for_window_activated("Document Window")
|
126
|
+
end
|
127
|
+
|
128
|
+
######################################################################
|
129
|
+
# Opens a new tab and loads the url entered, then waits for
|
130
|
+
# a dialog to be shown based on the url entered
|
131
|
+
#
|
132
|
+
# @param [String] dialog_name name of the dialog that will be opened
|
133
|
+
# (Pass a blank string for any window)
|
134
|
+
# @param [String] url to load
|
135
|
+
#
|
136
|
+
# @return [int] Window ID of the dialog opened or 0 if no window is opened
|
137
|
+
#
|
138
|
+
def open_dialog_with_url(dialog_name, url)
|
139
|
+
wait_start
|
140
|
+
opera_desktop_action("Open url in new page", url)
|
141
|
+
# The loading of the page will happen first then the dialog will be shown
|
142
|
+
wait_for_window_shown(dialog_name)
|
143
|
+
end
|
144
|
+
|
145
|
+
######################################################################
|
146
|
+
# Executes the action given by action_name, and waits for
|
147
|
+
# the window with window name win_name to close
|
148
|
+
#
|
149
|
+
# @example
|
150
|
+
# browser.close_window_with_action("New Preferences Dialog", "Cancel")
|
151
|
+
# browser.close_window_with_action("New Preferences Dialog", "Cancel", "1")
|
152
|
+
#
|
153
|
+
# @param [String] win_name name of the window that will be closed (Pass a blank string for any window)
|
154
|
+
# @param [String] action_name name of the action to execute to close the window
|
155
|
+
# @param [String] param optional parameter(s) to be supplied with the Opera action.
|
156
|
+
#
|
157
|
+
# @return [int] Window ID of the window closed or 0 if no window is closed
|
158
|
+
#
|
159
|
+
def close_window_with_action(win_name, action_name, *params)
|
160
|
+
wait_start
|
161
|
+
opera_desktop_action(action_name, *params)
|
162
|
+
wait_for_window_close(win_name)
|
163
|
+
end
|
164
|
+
|
165
|
+
alias_method :close_dialog_with_action, :close_window_with_action
|
166
|
+
|
167
|
+
######################################################################
|
168
|
+
# Presses the key, with optional modifiers, and waits for
|
169
|
+
# the window with window name win_name to close
|
170
|
+
#
|
171
|
+
# @example
|
172
|
+
# browser.close_window_with_key_press("New Preferences Dialog", "Esc")
|
173
|
+
# browser.close_window_with_key_press("New Preferences Dialog", "w", :ctrl)
|
174
|
+
#
|
175
|
+
# @param [String] win_name name of the window that will be closed (Pass a blank string for any window)
|
176
|
+
# @param [String] key key to press (e.g. "a" or "backspace")
|
177
|
+
# @param [Symbol] modifiers optional modifier(s) to hold down while pressing the key (e.g. :shift, :ctrl, :alt, :meta)
|
178
|
+
#
|
179
|
+
# @return [int] Window ID of the window closed or 0 if no window is closed
|
180
|
+
#
|
181
|
+
def close_window_with_key_press(win_name, key, *opts)
|
182
|
+
wait_start
|
183
|
+
key_press_direct(key, *opts)
|
184
|
+
wait_for_window_close(win_name)
|
185
|
+
end
|
186
|
+
|
187
|
+
alias_method :close_dialog_with_key_press, :close_window_with_key_press
|
188
|
+
|
189
|
+
######################################################################
|
190
|
+
# Close the dialog with name dialog_name, using the "Cancel" action
|
191
|
+
#
|
192
|
+
# @param [String] dialog_name name of the dialog that will be closed
|
193
|
+
# (Pass a blank string for any window)
|
194
|
+
#
|
195
|
+
# @return [int] Window ID of the dialog closed or 0 if no window is closed
|
196
|
+
#
|
197
|
+
def close_dialog(dialog_name)
|
198
|
+
wait_start
|
199
|
+
opera_desktop_action("Cancel")
|
200
|
+
wait_for_window_close(dialog_name)
|
201
|
+
end
|
202
|
+
|
203
|
+
######################################################################
|
204
|
+
# Sets the alignment of a toolbar or panel
|
205
|
+
#
|
206
|
+
# @param [String] toobar_name name of the panel or toolbar to change
|
207
|
+
# the alignment of
|
208
|
+
# @param [int] alignment of the toolbar to set
|
209
|
+
#
|
210
|
+
def set_alignment_with_action(toolbar_name, alignment)
|
211
|
+
opera_desktop_action("Set alignment", toolbar_name, alignment)
|
212
|
+
sleep(0.1)
|
213
|
+
end
|
214
|
+
|
215
|
+
######################################################################
|
216
|
+
# Retrieves an array of all widgets in the window with window
|
217
|
+
# name win_name
|
218
|
+
#
|
219
|
+
# @example
|
220
|
+
# browser.widgets(window_name).each do |quick_widget|
|
221
|
+
# puts quick_widget.to_s
|
222
|
+
# end
|
223
|
+
#
|
224
|
+
# @param win_name [String] name or [int] id of the window to retrieve the list of widgets from,
|
225
|
+
#
|
226
|
+
# @return [Array] Array of widgets retrieved from the window
|
227
|
+
#
|
228
|
+
def widgets(win_name)
|
229
|
+
@driver.getQuickWidgetList(win_name).map do |java_widget|
|
230
|
+
case java_widget.getType
|
231
|
+
when QuickWidget::WIDGET_ENUM_MAP[:button]
|
232
|
+
QuickButton.new(self,java_widget)
|
233
|
+
when QuickWidget::WIDGET_ENUM_MAP[:checkbox]
|
234
|
+
QuickCheckbox.new(self,java_widget)
|
235
|
+
when QuickWidget::WIDGET_ENUM_MAP[:dialogtab]
|
236
|
+
QuickDialogTab.new(self,java_widget)
|
237
|
+
when QuickWidget::WIDGET_ENUM_MAP[:dropdown]
|
238
|
+
QuickDropdown.new(self,java_widget)
|
239
|
+
when QuickWidget::WIDGET_ENUM_MAP[:editfield]
|
240
|
+
QuickEditField.new(self,java_widget)
|
241
|
+
when QuickWidget::WIDGET_ENUM_MAP[:label]
|
242
|
+
QuickLabel.new(self,java_widget)
|
243
|
+
when QuickWidget::WIDGET_ENUM_MAP[:radiobutton]
|
244
|
+
QuickRadioButton.new(self,java_widget)
|
245
|
+
when QuickWidget::WIDGET_ENUM_MAP[:treeview]
|
246
|
+
QuickTreeView.new(self,java_widget)
|
247
|
+
when QuickWidget::WIDGET_ENUM_MAP[:treeitem]
|
248
|
+
QuickTreeItem.new(self,java_widget)
|
249
|
+
when QuickWidget::WIDGET_ENUM_MAP[:thumbnail]
|
250
|
+
QuickTreeItem.new(self,java_widget)
|
251
|
+
else
|
252
|
+
QuickWidget.new(self,java_widget)
|
253
|
+
end
|
254
|
+
end.to_a
|
255
|
+
end
|
256
|
+
|
257
|
+
####################################################
|
258
|
+
# Retrieves an array of all windows
|
259
|
+
#
|
260
|
+
# @return [Array] Array of windows
|
261
|
+
#
|
262
|
+
def windows
|
263
|
+
@driver.getWindowList.map do |java_window|
|
264
|
+
QuickWindow.new(self,java_window)
|
265
|
+
end.to_a
|
266
|
+
end
|
267
|
+
|
268
|
+
#@private
|
269
|
+
# Retrieve all tabs
|
270
|
+
def open_pages
|
271
|
+
windows.select { |win| win.name == "Document Window" }
|
272
|
+
end
|
273
|
+
|
274
|
+
#@private
|
275
|
+
# Not needed as quick_tabs is def. below
|
276
|
+
#def tab_buttons
|
277
|
+
# widgets("Browser Window").select { | w | w.type == :tabbutton }
|
278
|
+
#end
|
279
|
+
|
280
|
+
#=begin
|
281
|
+
# Return collection for each widget type
|
282
|
+
# example browser.quick_buttons
|
283
|
+
# browser.quick_treeitems
|
284
|
+
# ....
|
285
|
+
#
|
286
|
+
WIDGET_ENUM_MAP.keys.each do |widget_type|
|
287
|
+
my_type = "quick_" << widget_type.to_s
|
288
|
+
type = my_type
|
289
|
+
if my_type == "quick_search" || my_type == "quick_checkbox"
|
290
|
+
my_type << "es"
|
291
|
+
else
|
292
|
+
my_type << "s"
|
293
|
+
end
|
294
|
+
define_method(my_type.to_sym) do |win|
|
295
|
+
widgets(win).select { |w| w.type == widget_type}
|
296
|
+
end
|
297
|
+
end
|
298
|
+
#=end
|
299
|
+
|
300
|
+
######################################################################
|
301
|
+
# Retrieves the name of a window based on it's id
|
302
|
+
#
|
303
|
+
# @param [int] win_id Window ID to retrieve the name for
|
304
|
+
#
|
305
|
+
# @return [String] Name of the window
|
306
|
+
#
|
307
|
+
def get_window_name(win_id)
|
308
|
+
@driver.getWindowName(win_id)
|
309
|
+
end
|
310
|
+
|
311
|
+
######################################################################
|
312
|
+
# Presses the key, with optional modifiers, and waits for loaded event
|
313
|
+
#
|
314
|
+
# @example
|
315
|
+
# browser.quick_toolbar(:name, "Document Toolbar").quick_addressfield(:name, "tba_address_field").\n
|
316
|
+
# type_text(text_to_type).should == text_to_type
|
317
|
+
# browser.load_page_with_key_press("Enter").should > 0
|
318
|
+
#
|
319
|
+
# @param [String] key key to press (e.g. "a" or "backspace")
|
320
|
+
# @param [Symbol] modifiers optional modifier(s) to hold down while pressing the key (e.g. :shift, :ctrl, :alt, :meta)
|
321
|
+
#
|
322
|
+
# @return [int] Window ID of the window loaded or 0 if no window is loaded
|
323
|
+
#
|
324
|
+
def load_page_with_key_press(key, *modifiers)
|
325
|
+
wait_start
|
326
|
+
key_press_direct(key, *modifiers)
|
327
|
+
wait_for_window_loaded("")
|
328
|
+
end
|
329
|
+
|
330
|
+
##############################################################################
|
331
|
+
# Clicks the element specified by method and selector,
|
332
|
+
# and waits for the window with name win_name to be shown
|
333
|
+
#
|
334
|
+
# @param [WebElement] element element to click
|
335
|
+
# @param [String] win_name Name of window to be shown
|
336
|
+
#
|
337
|
+
# @return [int] Window ID of the window shown or 0 if no window is shown
|
338
|
+
#
|
339
|
+
=begin
|
340
|
+
# or open_dialog_with_click(type, method, selector, win_name)
|
341
|
+
# open_dialog_with_click(:button, :id, "text", win_name)
|
342
|
+
=end
|
343
|
+
def open_dialog_with_click(method, selector, win_name)
|
344
|
+
wait_start
|
345
|
+
OperaWatir::WebElement.new(self, method, selector).click
|
346
|
+
wait_for_window_shown(win_name)
|
347
|
+
end
|
348
|
+
|
349
|
+
|
350
|
+
######################################################################
|
351
|
+
# Returns the full path to the Opera executable
|
352
|
+
#
|
353
|
+
# @return [String] Full path to the opera executable
|
354
|
+
#
|
355
|
+
def get_opera_path
|
356
|
+
@driver.getOperaPath()
|
357
|
+
end
|
358
|
+
|
359
|
+
######################################################################
|
360
|
+
# Returns the full path to the Opera large preferences folder
|
361
|
+
#
|
362
|
+
# @return [String] Full path to the large preferences folder
|
363
|
+
#
|
364
|
+
def get_large_preferences_path
|
365
|
+
@driver.getLargePreferencesPath()
|
366
|
+
end
|
367
|
+
|
368
|
+
######################################################################
|
369
|
+
# Returns the full path to the Opera small preferences folder
|
370
|
+
#
|
371
|
+
# @return [String] Full path to the small preferences folder
|
372
|
+
#
|
373
|
+
def get_small_preferences_path
|
374
|
+
@driver.getSmallPreferencesPath()
|
375
|
+
end
|
376
|
+
|
377
|
+
######################################################################
|
378
|
+
# Returns the full path to the Opera cache preferences folder
|
379
|
+
#
|
380
|
+
# @return [String] Full path to the cache preferences folder
|
381
|
+
#
|
382
|
+
def get_cache_preferences_path
|
383
|
+
@driver.getCachePreferencesPath()
|
384
|
+
end
|
385
|
+
|
386
|
+
######################################################################
|
387
|
+
# Returns true if the test is running on Mac
|
388
|
+
#
|
389
|
+
# @return [Boolean] true we the operating system is Mac, otherwise false
|
390
|
+
#
|
391
|
+
def mac?
|
392
|
+
Config::CONFIG['target_os'] == "darwin"
|
393
|
+
end
|
394
|
+
|
395
|
+
def linux?
|
396
|
+
Config::CONFIG['target_os'] == "linux"
|
397
|
+
end
|
398
|
+
|
399
|
+
# @private
|
400
|
+
# Special method to access the driver
|
401
|
+
attr_reader :driver
|
402
|
+
|
403
|
+
######################################################################
|
404
|
+
# Clear all private data (as in Delete Private Data Dialog)
|
405
|
+
#
|
406
|
+
# @return [int] 0 if operation failed, else > 0
|
407
|
+
#
|
408
|
+
def clear_all_private_data
|
409
|
+
|
410
|
+
#FIXME: Set CheckFlags to uncheck to prevent storing the settings used here
|
411
|
+
|
412
|
+
win_id = open_dialog_with_action("Clear Private Data Dialog", "Delete private data")
|
413
|
+
return 0 if win_id == 0
|
414
|
+
|
415
|
+
#Ensure is Expanded
|
416
|
+
if quick_button(:name, "Destails_expand").value == 0
|
417
|
+
quick_button(:name, "Destails_expand").toggle_with_click
|
418
|
+
end
|
419
|
+
|
420
|
+
quick_checkboxes("Clear Private Data Dialog").each do |box|
|
421
|
+
box.toggle_with_click unless box.checked?
|
422
|
+
end
|
423
|
+
|
424
|
+
#Delete all
|
425
|
+
win_id = quick_button(:name, "button_OK").close_dialog_with_click("Clear Private Data Dialog")
|
426
|
+
|
427
|
+
#FIXME: Reset CheckFlags
|
428
|
+
|
429
|
+
win_id
|
430
|
+
end
|
431
|
+
|
432
|
+
######################################################################
|
433
|
+
# Clear typed and visited history
|
434
|
+
#
|
435
|
+
def clear_history
|
436
|
+
#TODO: Use Delete Private Data Dialog?
|
437
|
+
opera_desktop_action("Clear visited history")
|
438
|
+
opera_desktop_action("Clear typed in history")
|
439
|
+
end
|
440
|
+
|
441
|
+
######################################################################
|
442
|
+
#
|
443
|
+
# Clear disk cache
|
444
|
+
#
|
445
|
+
def clear_cache
|
446
|
+
#TODO: Use Delete Private Data Dialog?
|
447
|
+
opera_desktop_action("Clear disk cache")
|
448
|
+
end
|
449
|
+
|
450
|
+
######################################################################
|
451
|
+
#
|
452
|
+
# Close all open tabs (except last one)
|
453
|
+
#
|
454
|
+
def close_all_tabs
|
455
|
+
#The collection has the activate tab first and then the rest sorted on number, so resort to get on descending position
|
456
|
+
quick_tabbuttons("Browser Window").sort {|t1, t2| (t2.position <=> t1.position) }.each do |btn|
|
457
|
+
#Tab button is in Browser window which is prob not the active window,
|
458
|
+
#so we cannot do this the easy way
|
459
|
+
#btn.quick_button(:name, "pb_CloseButton").close_window_with_click("Document Window") unless btn.position == 0
|
460
|
+
#puts "Current tab = #{btn}"
|
461
|
+
if btn.position != 0 or btn.value > 1 then
|
462
|
+
quick_window(:name, "Browser Window").quick_tab(:pos, btn.position).quick_button(:name, "pb_CloseButton").close_window_with_click("Document Window")
|
463
|
+
end
|
464
|
+
end
|
465
|
+
end
|
466
|
+
|
467
|
+
#####################################################################
|
468
|
+
#
|
469
|
+
# Close all open dialogs
|
470
|
+
#
|
471
|
+
def close_all_dialogs
|
472
|
+
win_id = driver.getActiveWindowID()
|
473
|
+
until quick_window(:id, win_id).type != :dialog do
|
474
|
+
win = quick_window(:id, driver.getActiveWindowID())
|
475
|
+
if win.type == :dialog
|
476
|
+
close_dialog(win.name)
|
477
|
+
if (driver.getActiveWindowID() != win_id)
|
478
|
+
win_id = driver.getActiveWindowID()
|
479
|
+
else
|
480
|
+
break
|
481
|
+
end
|
482
|
+
end
|
483
|
+
end
|
484
|
+
end
|
485
|
+
|
486
|
+
|
487
|
+
=begin
|
488
|
+
TODO:
|
489
|
+
def delete_cookies
|
490
|
+
def reset_main_window
|
491
|
+
=end
|
492
|
+
|
493
|
+
private
|
494
|
+
# Gets the parent widget name of which there is none here
|
495
|
+
def parent_widget
|
496
|
+
nil
|
497
|
+
end
|
498
|
+
|
499
|
+
# Gets the window id to use for the search
|
500
|
+
def window_id
|
501
|
+
-1
|
502
|
+
end
|
503
|
+
end
|
504
|
+
|
505
|
+
end
|
506
|
+
|