operawatir 0.3-jruby → 0.3.2-jruby

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. data/Gemfile +6 -2
  2. data/LICENSE +1 -1
  3. data/Rakefile +7 -8
  4. data/VERSION +1 -1
  5. data/bin/desktopwatir +3 -0
  6. data/bin/operawatir +2 -2
  7. data/lib/operadriver/webdriver-opera.jar +0 -0
  8. data/lib/operawatir.rb +14 -8
  9. data/lib/operawatir/browser.rb +49 -38
  10. data/lib/operawatir/compat/collection.rb +6 -0
  11. data/lib/operawatir/compat/element.rb +5 -2
  12. data/lib/operawatir/compat/element_finders.rb +19 -0
  13. data/lib/operawatir/desktop-waiter.rb +144 -0
  14. data/lib/operawatir/desktop_browser.rb +506 -0
  15. data/lib/operawatir/desktop_common.rb +111 -0
  16. data/lib/operawatir/desktop_container.rb +252 -0
  17. data/lib/operawatir/desktop_enums.rb +42 -0
  18. data/lib/operawatir/desktop_exceptions.rb +16 -0
  19. data/lib/operawatir/element.rb +6 -6
  20. data/lib/operawatir/exceptions.rb +3 -0
  21. data/lib/operawatir/keys.rb +116 -0
  22. data/lib/operawatir/platform.rb +59 -0
  23. data/lib/operawatir/quickwidgets.rb +3 -0
  24. data/lib/operawatir/quickwidgets/quick_addressfield.rb +23 -0
  25. data/lib/operawatir/quickwidgets/quick_button.rb +151 -0
  26. data/lib/operawatir/quickwidgets/quick_checkbox.rb +58 -0
  27. data/lib/operawatir/quickwidgets/quick_dialogtab.rb +23 -0
  28. data/lib/operawatir/quickwidgets/quick_dropdown.rb +27 -0
  29. data/lib/operawatir/quickwidgets/quick_editfield.rb +115 -0
  30. data/lib/operawatir/quickwidgets/quick_label.rb +12 -0
  31. data/lib/operawatir/quickwidgets/quick_radiobutton.rb +11 -0
  32. data/lib/operawatir/quickwidgets/quick_searchfield.rb +25 -0
  33. data/lib/operawatir/quickwidgets/quick_tab.rb +66 -0
  34. data/lib/operawatir/quickwidgets/quick_thumbnail.rb +26 -0
  35. data/lib/operawatir/quickwidgets/quick_toolbar.rb +11 -0
  36. data/lib/operawatir/quickwidgets/quick_treeitem.rb +157 -0
  37. data/lib/operawatir/quickwidgets/quick_treeview.rb +27 -0
  38. data/lib/operawatir/quickwidgets/quick_widget.rb +369 -0
  39. data/lib/operawatir/quickwidgets/quick_window.rb +150 -0
  40. data/lib/operawatir/selector.rb +1 -1
  41. data/lib/operawatir/version.rb +0 -1
  42. data/lib/operawatir/window.rb +9 -0
  43. data/operawatir.gemspec +382 -0
  44. data/spec/new_watirspec/browser_spec.rb +279 -0
  45. data/spec/new_watirspec/clipboard_spec.rb +79 -0
  46. data/spec/new_watirspec/collection_spec.rb +387 -0
  47. data/spec/new_watirspec/element_spec.rb +456 -0
  48. data/spec/new_watirspec/guards.rb +39 -0
  49. data/spec/new_watirspec/keys_spec.rb +206 -0
  50. data/spec/new_watirspec/server.rb +91 -0
  51. data/spec/new_watirspec/watirspec_helper.rb +62 -0
  52. data/spec/new_watirspec/window_spec.rb +370 -0
  53. data/utils/launchers/launcher-mac +0 -0
  54. metadata +191 -28
  55. data/.gitmodules +0 -3
@@ -0,0 +1,111 @@
1
+ module OperaWatir
2
+ # @private
3
+ # This module is to share functions in the driver between modules so
4
+ # should not be in the documentation
5
+ module DesktopCommon
6
+ include DesktopEnums
7
+
8
+ private
9
+ def opera_desktop_action(action_name, *params)
10
+ data = 0
11
+ data_string = ""
12
+ data_string_param = ""
13
+
14
+ # Sort the parameters into the variables based
15
+ # on type and order
16
+ params.each { |param|
17
+ if param.is_a? Integer
18
+ data = param
19
+ end
20
+
21
+ if param.is_a? String
22
+ if data_string.empty?
23
+ data_string = param
24
+ elsif
25
+ data_string_param = param
26
+ end
27
+ end
28
+ }
29
+
30
+ #puts "data: " + data.to_s
31
+ #puts "data_string: " + data_string
32
+ #puts "data_string_param: " + data_string_param
33
+
34
+ @driver.operaDesktopAction(action_name, data, data_string, data_string_param)
35
+ end
36
+
37
+ def key_press_direct(key, *opts)
38
+ list = Java::JavaUtil::ArrayList.new
39
+ opts.each { |mod| list << KEYMODIFIER_ENUM_MAP[mod] }
40
+ driver.keyPress(key, list)
41
+ end
42
+
43
+ def key_down(key, *opts)
44
+ puts "keydown"
45
+ list = Java::JavaUtil::ArrayList.new
46
+ opts.each { |mod| list << KEYMODIFIER_ENUM_MAP[mod] }
47
+ driver.keyDown(key, list)
48
+ end
49
+
50
+ def key_up(key, *opts)
51
+ puts "keyup"
52
+ list = Java::JavaUtil::ArrayList.new
53
+ opts.each { |mod| list << KEYMODIFIER_ENUM_MAP[mod] }
54
+ driver.keyUp(key, list)
55
+ end
56
+
57
+ # Private wait functions
58
+ #
59
+ def wait_start
60
+ driver.waitStart()
61
+ end
62
+
63
+ def wait_for_window_shown(win_name = "")
64
+ driver.waitForWindowShown(win_name)
65
+ end
66
+
67
+ def wait_for_window_updated(win_name = "")
68
+ driver.waitForWindowUpdated(win_name)
69
+ end
70
+
71
+ def wait_for_window_activated(win_name = "")
72
+ driver.waitForWindowActivated(win_name)
73
+ end
74
+
75
+ def wait_for_window_close(win_name = "")
76
+ driver.waitForWindowClose(win_name)
77
+ end
78
+
79
+ def wait_for_window_loaded(win_name = "")
80
+ win_id = driver.waitForWindowLoaded(win_name)
81
+ # Hack to allow for Javascript focus events and the like
82
+ # We need to increase this until we have fixed the bug with the
83
+ # tab title taking extra time to change
84
+ sleep(0.5)
85
+ win_id
86
+ end
87
+
88
+ def wait_for_widget_enabled
89
+ max_timeout = 1.5
90
+ curr_timeout = 0.0
91
+ step = 0.1
92
+
93
+ while curr_timeout < max_timeout
94
+ if element(true).isEnabled == true
95
+ break
96
+ end
97
+
98
+ sleep(step)
99
+ curr_timeout += step
100
+ end
101
+
102
+ # Check we didn't exceed the timeout
103
+ if curr_timeout >= max_timeout
104
+ return false
105
+ end
106
+
107
+ # Return true
108
+ true
109
+ end
110
+ end
111
+ end
@@ -0,0 +1,252 @@
1
+ module OperaWatir
2
+ module DesktopContainer
3
+
4
+ ######################################################################
5
+ # Method for accessing a button element
6
+ #
7
+ # @example
8
+ # browser.quick_button(:name, "button_OK")
9
+ #
10
+ # @param [String] how Method to find the element. :name, :text or :string_id of the button
11
+ # @param [String] what Search text to find the element with. Currently name, text or string_id
12
+ # of the button
13
+ #
14
+ # @return [Object] button object if found, otherwise nil
15
+ #
16
+ def quick_button(how, what)
17
+ QuickButton.new(self, how, what, parent_widget, window_id)
18
+ end
19
+
20
+ ######################################################################
21
+ # Method for accessing a tab button element
22
+ #
23
+ # @param [String] how Method to find the element. :text and :pos is supported.
24
+ # @param [String, FixNum] what Search text or position to find the element with.
25
+ # Currently text or position of the tab button, first tab button has position 0.
26
+ #
27
+ # @example
28
+ # browser.quick_window(:name, "Browser Window").quick_toolbar(:name, "Pagebar").quick_tab(:pos, 1)
29
+ # browser.quick_window(:name, "Browser Window").quick_toolbar(:name, "Pagebar").quick_tab(:text, "Connect to Debugger")
30
+ #
31
+ # @return [Object] tab button object if found, otherwise nil
32
+ #
33
+ def quick_tab(how, what)
34
+ if how == :pos
35
+ if what.is_a? Fixnum
36
+ what = [0, what]
37
+ end
38
+ end
39
+ QuickTab.new(self, how, what, parent_widget, window_id)
40
+ end
41
+
42
+ ######################################################################
43
+ # Method for accessing a checkbox element
44
+ #
45
+ # @example
46
+ # browser.quick_checkbox(:name, "Enable_wand_checkbox")
47
+ #
48
+ # @param [String] how Method to find the element. :name, :text or :string_id
49
+ # @param [String] what Search text to find element with.
50
+ #
51
+ # @return [Object] checkbox object if found, otherwise nil
52
+ #
53
+ def quick_checkbox(how, what)
54
+ QuickCheckbox.new(self, how, what, parent_widget, window_id)
55
+ end
56
+
57
+ ######################################################################
58
+ # Method for accessing a tab on a tabbed dialog
59
+ #
60
+ # @example
61
+ # browser.quick_dialogtab(:name, "tab_prefs_forms")
62
+ #
63
+ # @param [String] how Method to find the element. :name, :string_id or :text
64
+ # @param [String] what Search text to find the element with.
65
+ #
66
+ # @return [Object] dialog tab object if found, otherwise nil
67
+ #
68
+ def quick_dialogtab(how, what)
69
+ QuickDialogTab.new(self, how, what, parent_widget, window_id)
70
+ end
71
+
72
+ ######################################################################
73
+ # Method for accessing a combobox (i.e. dropdown) element
74
+ #
75
+ # @example
76
+ # browser.quick_dropdown(:name, "Startup_mode_dropdown")
77
+ #
78
+ # @param [String] how Method to find the element. :name, :string_id or :text
79
+ # @param [String] what Search text to find the element with.
80
+ #
81
+ # @return [Object] drop down object if found, otherwise nil
82
+ #
83
+ def quick_dropdown(how, what)
84
+ QuickDropdown.new(self, how, what, parent_widget, window_id)
85
+ end
86
+
87
+
88
+ ######################################################################
89
+ # Method for accessing an edit or multiedit element
90
+ #
91
+ # @example
92
+ # browser.quick_editfield(:name, "Startpage_edit")
93
+ #
94
+ # @param [String] how Method to find the element. :name, :string_id or :text
95
+ # @param [String] what Search text to find the element with.
96
+ #
97
+ # @return [Object] edit field object if found, otherwise nil
98
+ #
99
+ def quick_editfield(how, what)
100
+ QuickEditField.new(self, how, what, parent_widget, window_id)
101
+ end
102
+
103
+ ######################################################################
104
+ # Method for accessing a label element
105
+ #
106
+ # @example
107
+ # browser.quick_label(:name, "label_for_Popups_dropdown")
108
+ #
109
+ # @param [String] how Method to find the element. :name, :string_id or :text
110
+ # @param [String] what Search text to find the element with.
111
+ #
112
+ # @return [Object] label object if found, otherwise nil
113
+ #
114
+ def quick_label(how, what)
115
+ QuickLabel.new(self, how, what, parent_widget, window_id)
116
+ end
117
+
118
+ ######################################################################
119
+ # Method for accessing a radio button element
120
+ #
121
+ # @example
122
+ # browser.quick_radiobutton(:name, "Accept_cookies_radio")
123
+ #
124
+ # @param [String] how Method to find the element. :name, :string_id or :text
125
+ # @param [String] what Search text to find the element with.
126
+ #
127
+ # @return [Object] radio button object if found, otherwise nil
128
+ #
129
+ def quick_radiobutton(how, what)
130
+ QuickRadioButton.new(self, how, what, parent_widget, window_id)
131
+ end
132
+
133
+ ######################################################################
134
+ # Method for accessing a tree view element
135
+ #
136
+ # @example
137
+ # browser.quick_treeview(:name, "Web_search_treeview")
138
+ #
139
+ # @param [String] how Method to find the element. :name, :string_id or :text
140
+ # @param [String] what Search text to find the element with.
141
+ #
142
+ # @return [Object] treeview object if found, otherwise nil
143
+ #
144
+ def quick_treeview(how, what)
145
+ QuickTreeView.new(self, how, what, parent_widget, window_id)
146
+ end
147
+
148
+ ######################################################################
149
+ # Method for accessing an addressfield object
150
+ #
151
+ # @example
152
+ # browser.quick_toolbar(:name, "Document Toolbar").quick_addressfield(:name, "tba_addressfield")
153
+ #
154
+ # @param [String] how Method to find the element. :name, :string_id or :text
155
+ # @param [String] what Search text to find the element with.
156
+ #
157
+ # @return [Object] addressfield object if found, otherwise nil
158
+ #
159
+ def quick_addressfield(how, what)
160
+ QuickAddressField.new(self, how, what, parent_widget, window_id)
161
+ end
162
+
163
+ ######################################################################
164
+ # Method for accessing a searchfield element
165
+ #
166
+ # @example
167
+ # browser.quick_searchfield(:name, "Web_search_searchfield")
168
+ #
169
+ # @param [String] how Method to find the element. :name, :string_id or :text
170
+ # @param [String] what Search text to find the element with.
171
+ #
172
+ # @return [Object] searchfield object if found, otherwise nil
173
+ #
174
+ def quick_searchfield(how, what)
175
+ QuickSearchField.new(self, how, what, parent_widget, window_id)
176
+ end
177
+
178
+ ######################################################################
179
+ # Method for accessing a toolbar element
180
+ #
181
+ # @example
182
+ # browser.quick_toolbar(:name, "Document_toolbar")
183
+ #
184
+ # @param [String] how Method to find the element. :name, :string_id or :text
185
+ # @param [String] what Search text to find the element with.
186
+ #
187
+ # @return [Object] toolbar object if found, otherwise nil
188
+ #
189
+ def quick_toolbar(how, what)
190
+ QuickToolbar.new(self, how, what, parent_widget, window_id)
191
+ end
192
+
193
+ ######################################################################
194
+ # Method for accessing a tree item in a treeview
195
+ #
196
+ # @example
197
+ # browser.quick_treeview(:name, "Server_treeview").quick_treeitem(:pos, [2,0])
198
+ #
199
+ # @param [String] how Method to find the element. :name, :string_id or :text
200
+ # @param [String] what Search text to find the element with. Text or position
201
+ # of treeitem. Position is specified as [row, column]
202
+ #
203
+ # @return [Object] treeitem object if found, otherwise nil
204
+ #
205
+ def quick_treeitem(how, what)
206
+ QuickTreeItem.new(self, how, what, parent_widget, window_id)
207
+ end
208
+
209
+ ######################################################################
210
+ # Method for accessing a thumbnail (speeddial, thumbnail when hovering tab groups)
211
+ #
212
+ # @example
213
+ # browser.quick_thumbnail(:name, "Thumbnail 1")
214
+ # browser.quick_thumbnail(:name, "Speed Dial 2")
215
+ #
216
+ # @param [String] how Method to find the element. :name, :string_id or :text
217
+ # @param [String] what Search text to find the element with. Text or position
218
+ # of treeitem. Position is specified as [row, column]
219
+ #
220
+ # @return [Object] thumbnail object if found, otherwise nil
221
+ #
222
+ def quick_thumbnail(how, what)
223
+ if how == :pos
224
+ if what.is_a? Fixnum
225
+ what = [0, what]
226
+ end
227
+ end
228
+ QuickThumbnail.new(self, how, what, parent_widget, window_id)
229
+ end
230
+
231
+ ######################################################################
232
+ # Method for accessing a window
233
+ #
234
+ # @example
235
+ # browser.quick_window(:name, "Browser Window")
236
+ # browser.quick_window(:name, "Document Window")
237
+ # browser.quick_window(:name, "Cycler Window")
238
+ #
239
+ # @param [String] how Method to find the element. Currently only :name is supported
240
+ # @param [String] what or [int] window_id Search text to find the element with. Name of window
241
+ # or the windows window_id
242
+ #
243
+ #
244
+ # @return [Object] window object if found, otherwise nil
245
+ #
246
+ def quick_window(how, what)
247
+ QuickWindow.new(self, how, what)
248
+ end
249
+
250
+ end
251
+ end
252
+
@@ -0,0 +1,42 @@
1
+ module OperaWatir
2
+ # @private
3
+ # Documentation doesn't work with these dynamic enums so just leave them out
4
+ module DesktopEnums
5
+
6
+ # Enum for the key/mouse modifiers
7
+ KEYMODIFIER_ENUM_MAP = SystemInputProtos::ModifierPressed.constants.inject({}) do |acc, const|
8
+ acc[const.to_s.downcase.to_sym] = SystemInputProtos::ModifierPressed.const_get(const)
9
+ acc
10
+ end
11
+
12
+ # Enum for the mouse buttons
13
+ MOUSEBUTTON_ENUM_MAP = SystemInputProtos::MouseInfo::MouseButton.constants.inject({}) do |acc, const|
14
+ acc[const.to_s.downcase.to_sym] = SystemInputProtos::MouseInfo::MouseButton.const_get(const)
15
+ acc
16
+ end
17
+
18
+ # Enum for the widget types
19
+ WIDGET_ENUM_MAP = DesktopWmProtos::QuickWidgetInfo::QuickWidgetType.constants.inject({}) do |acc, const|
20
+ #puts const.inspect
21
+ acc[const.to_s.downcase.to_sym] = DesktopWmProtos::QuickWidgetInfo::QuickWidgetType.const_get(const)
22
+ acc
23
+ end
24
+
25
+ WINDOW_ENUM_MAP = DesktopWmProtos::DesktopWindowInfo::DesktopWindowType.constants.inject({}) do |acc, const|
26
+ #puts const.inspect
27
+ acc[const.to_s.downcase.to_sym] = DesktopWmProtos::DesktopWindowInfo::DesktopWindowType.const_get(const)
28
+ acc
29
+ end
30
+
31
+ WIDGET_SEARCHTYPE_ENUM_MAP = DesktopWmProtos::QuickWidgetSearch::QuickWidgetSearchType.constants.inject({}) do |acc, const|
32
+ acc[const.to_s.downcase.to_sym] = DesktopWmProtos::QuickWidgetSearch::QuickWidgetSearchType.const_get(const)
33
+ acc
34
+ end
35
+
36
+ DROPPOSITION_ENUM_MAP = QuickWidget::DropPosition.constants.inject({}) do |acc, const|
37
+ #puts const.inspect
38
+ acc[const.to_s.downcase.to_sym] = QuickWidget::DropPosition.const_get(const)
39
+ acc
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,16 @@
1
+ module OperaWatir::DesktopExceptions
2
+ include OperaWatir::Exceptions
3
+
4
+ # @example
5
+ # begin
6
+ # ...
7
+ # rescue OperaWatirException
8
+ # end
9
+
10
+ # Raised when a method is called on a control that is not visible
11
+ # corresponding element.
12
+ class WidgetNotVisibleException < OperaWatirException; end
13
+ class UnsupportedActionException < OperaWatirException; end
14
+ class WidgetDisabledException < OperaWatirException; end
15
+
16
+ end
@@ -59,8 +59,6 @@ class OperaWatir::Element
59
59
  def_delegator :node, :isEnabled, :enabled?
60
60
  def_delegator :node, :isSelected, :checked?
61
61
 
62
- alias_method :set?, :checked?
63
-
64
62
  def_delegator :node, :isSelected, :selected?
65
63
 
66
64
  def_delegator :node, :toggle, :toggle_check!
@@ -79,15 +77,13 @@ class OperaWatir::Element
79
77
  end
80
78
 
81
79
  def check!
82
- result = node.toggle
83
- if(result != true)
80
+ if not selected?
84
81
  node.toggle
85
82
  end
86
83
  end
87
84
 
88
85
  def uncheck!
89
- result = node.toggle
90
- if(result != false)
86
+ if selected?
91
87
  node.toggle
92
88
  end
93
89
  end
@@ -137,6 +133,10 @@ class OperaWatir::Element
137
133
 
138
134
  alias_method :set, :text=
139
135
 
136
+ def send_keys(*list)
137
+ raise Exceptions::NotImplementedException
138
+ end
139
+
140
140
  def trigger!(event, x = 0, y = 0)
141
141
  loc = location
142
142
  x += loc[:x]