operawatir 0.4.3.pre1-jruby → 0.5-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 (98) hide show
  1. data/.gitmodules +1 -1
  2. data/CHANGES +230 -0
  3. data/Gemfile +4 -0
  4. data/Rakefile +3 -2
  5. data/VERSION +1 -1
  6. data/bin/desktopwatir +1 -1
  7. data/bin/operawatir +16 -4
  8. data/lib/operadriver/guava-r09.jar +0 -0
  9. data/lib/operadriver/operadriver-v0.7.2.jar +0 -0
  10. data/lib/operadriver/selenium-nodeps-20100909.jar +0 -0
  11. data/lib/operawatir.rb +10 -3
  12. data/lib/operawatir/actions.rb +111 -0
  13. data/lib/operawatir/browser.rb +24 -20
  14. data/lib/operawatir/clickable_item.rb +68 -0
  15. data/lib/operawatir/compat.rb +4 -4
  16. data/lib/operawatir/compat/collection.rb +1 -1
  17. data/lib/operawatir/compat/element.rb +1 -1
  18. data/lib/operawatir/compat/window.rb +4 -3
  19. data/lib/operawatir/desktop_browser.rb +299 -95
  20. data/lib/operawatir/desktop_common.rb +88 -23
  21. data/lib/operawatir/desktop_container.rb +103 -34
  22. data/lib/operawatir/desktop_enums.rb +4 -4
  23. data/lib/operawatir/desktop_exceptions.rb +2 -2
  24. data/lib/operawatir/desktop_helper.rb +31 -8
  25. data/lib/operawatir/element.rb +6 -2
  26. data/lib/operawatir/exceptions.rb +4 -4
  27. data/lib/operawatir/helper.rb +6 -6
  28. data/lib/operawatir/keys.rb +4 -4
  29. data/lib/operawatir/preferences.rb +126 -155
  30. data/lib/operawatir/quickwidgets.rb +3 -3
  31. data/lib/operawatir/quickwidgets/quick_addressfield.rb +12 -5
  32. data/lib/operawatir/quickwidgets/quick_button.rb +39 -53
  33. data/lib/operawatir/quickwidgets/quick_checkbox.rb +6 -6
  34. data/lib/operawatir/quickwidgets/quick_dialogtab.rb +5 -5
  35. data/lib/operawatir/quickwidgets/quick_dropdown.rb +28 -4
  36. data/lib/operawatir/quickwidgets/quick_dropdownitem.rb +46 -0
  37. data/lib/operawatir/quickwidgets/quick_editfield.rb +16 -13
  38. data/lib/operawatir/quickwidgets/quick_label.rb +1 -1
  39. data/lib/operawatir/quickwidgets/quick_menu.rb +155 -0
  40. data/lib/operawatir/quickwidgets/quick_menuitem.rb +387 -0
  41. data/lib/operawatir/quickwidgets/quick_searchfield.rb +7 -4
  42. data/lib/operawatir/quickwidgets/quick_tab.rb +23 -12
  43. data/lib/operawatir/quickwidgets/quick_thumbnail.rb +4 -4
  44. data/lib/operawatir/quickwidgets/quick_toolbar.rb +1 -1
  45. data/lib/operawatir/quickwidgets/quick_treeitem.rb +45 -29
  46. data/lib/operawatir/quickwidgets/quick_treeview.rb +2 -2
  47. data/lib/operawatir/quickwidgets/quick_widget.rb +267 -77
  48. data/lib/operawatir/quickwidgets/quick_window.rb +64 -38
  49. data/lib/operawatir/screenshot.rb +1 -1
  50. data/lib/operawatir/utils.rb +31 -0
  51. data/lib/operawatir/window.rb +1 -1
  52. data/operawatir.gemspec +38 -132
  53. data/spec/operawatir/core/actions_spec.rb +202 -0
  54. data/spec/operawatir/core/browser_spec.rb +8 -8
  55. data/spec/operawatir/core/element_spec.rb +11 -2
  56. data/spec/operawatir/core/keys_spec.rb +50 -2
  57. data/spec/operawatir/core/preferences_spec.rb +44 -128
  58. data/spec/operawatir/core/spatnav_spec.rb +16 -16
  59. data/spec/operawatir/core/utils_spec.rb +47 -0
  60. data/spec/operawatir/core/window_spec.rb +1 -1
  61. data/spec/operawatir/desktop/desktopbrowser_spec.rb +191 -22
  62. data/spec/operawatir/desktop/quickbutton_spec.rb +197 -164
  63. data/spec/operawatir/desktop/quickcheckbox_spec.rb +12 -12
  64. data/spec/operawatir/desktop/quickdialogtab_spec.rb +11 -11
  65. data/spec/operawatir/desktop/quickdropdown_spec.rb +25 -25
  66. data/spec/operawatir/desktop/quickeditfield_spec.rb +31 -31
  67. data/spec/operawatir/desktop/quickmenu_spec.rb +57 -0
  68. data/spec/operawatir/desktop/quickmenuitem_spec.rb +168 -0
  69. data/spec/operawatir/desktop/quicktab_spec.rb +26 -15
  70. data/spec/operawatir/desktop/quickthumbnail_spec.rb +18 -4
  71. data/spec/operawatir/desktop/quicktreeitem_spec.rb +72 -72
  72. data/spec/operawatir/desktop/quicktreeview_spec.rb +13 -13
  73. data/spec/operawatir/desktop/quickwidget_spec.rb +51 -13
  74. data/spec/operawatir/desktop/quickwindow_spec.rb +4 -0
  75. data/spec/operawatir/desktop/shared/shared.rb +25 -9
  76. data/spec/operawatir/fixtures/draggableLists.html +67 -0
  77. data/spec/operawatir/fixtures/formSelectionPage.html +46 -0
  78. data/spec/operawatir/fixtures/js/jquery-1.4.4.min.js +167 -0
  79. data/spec/operawatir/fixtures/js/jquery-ui-1.8.10.custom.min.js +782 -0
  80. data/spec/operawatir/fixtures/keys.html +40 -0
  81. data/spec/operawatir/fixtures/label_submit.html +5 -0
  82. data/spec/operawatir/fixtures/mouse.html +59 -0
  83. data/spec/operawatir/fixtures/simple.html +10 -0
  84. data/spec/operawatir/matchers.rb +20 -19
  85. data/spec/operawatir/watirspec_desktophelper.rb +51 -3
  86. data/spec/operawatir/watirspec_helper.rb +0 -2
  87. metadata +91 -220
  88. data/lib/operadriver/client-combined-nodeps.jar +0 -0
  89. data/lib/operadriver/webdriver-opera.jar +0 -0
  90. data/spec/watir3/browser_spec.rb +0 -190
  91. data/spec/watir3/clipboard_spec.rb +0 -64
  92. data/spec/watir3/collection_spec.rb +0 -387
  93. data/spec/watir3/element_spec.rb +0 -474
  94. data/spec/watir3/guards.rb +0 -39
  95. data/spec/watir3/keys_spec.rb +0 -204
  96. data/spec/watir3/server.rb +0 -91
  97. data/spec/watir3/watirspec_helper.rb +0 -62
  98. data/spec/watir3/window_spec.rb +0 -295
@@ -1,19 +1,61 @@
1
1
  module OperaWatir
2
2
  # @private
3
- # This module is to share functions in the driver between modules so
3
+ # This module is to share functions in the driver between modules so
4
4
  # should not be in the documentation
5
5
  module DesktopCommon
6
6
  include DesktopEnums
7
7
 
8
- private
8
+ private
9
+ def widgets(window)
10
+
11
+ # If window specifies window name, and the active window has this name
12
+ # use its id to get the widgets,
13
+ if window.is_a? String
14
+ active_win_id = driver.getActiveQuickWindowID()
15
+ active_win_name = driver.getQuickWindowName(active_win_id)
16
+
17
+ #If the active window is of same type, then grab that one, not first
18
+ if active_win_name == window #e.g. Both Document Window
19
+ window = active_win_id
20
+ end
21
+ end
22
+ driver.getQuickWidgetList(window).map do |java_widget|
23
+ case java_widget.getType
24
+ when QuickWidget::WIDGET_ENUM_MAP[:button]
25
+ QuickButton.new(self,java_widget)
26
+ when QuickWidget::WIDGET_ENUM_MAP[:checkbox]
27
+ QuickCheckbox.new(self,java_widget)
28
+ when QuickWidget::WIDGET_ENUM_MAP[:dialogtab]
29
+ QuickDialogTab.new(self,java_widget)
30
+ when QuickWidget::WIDGET_ENUM_MAP[:dropdown]
31
+ QuickDropdown.new(self,java_widget)
32
+ when QuickWidget::WIDGET_ENUM_MAP[:editfield]
33
+ QuickEditField.new(self,java_widget)
34
+ when QuickWidget::WIDGET_ENUM_MAP[:label]
35
+ QuickLabel.new(self,java_widget)
36
+ when QuickWidget::WIDGET_ENUM_MAP[:radiobutton]
37
+ QuickRadioButton.new(self,java_widget)
38
+ when QuickWidget::WIDGET_ENUM_MAP[:treeview]
39
+ QuickTreeView.new(self,java_widget)
40
+ when QuickWidget::WIDGET_ENUM_MAP[:treeitem]
41
+ QuickTreeItem.new(self,java_widget)
42
+ when QuickWidget::WIDGET_ENUM_MAP[:thumbnail]
43
+ QuickTreeItem.new(self,java_widget)
44
+ else
45
+ QuickWidget.new(self,java_widget)
46
+ end
47
+ end.to_a
48
+ end
49
+
50
+
9
51
  def opera_desktop_action(action_name, *params)
10
52
  data = 0
11
53
  data_string = ""
12
54
  data_string_param = ""
13
-
55
+
14
56
  # Sort the parameters into the variables based
15
57
  # on type and order
16
- params.each { |param|
58
+ params.each { |param|
17
59
  if param.is_a? Integer
18
60
  data = param
19
61
  end
@@ -21,16 +63,16 @@ private
21
63
  if param.is_a? String
22
64
  if data_string.empty?
23
65
  data_string = param
24
- elsif
66
+ elsif
25
67
  data_string_param = param
26
68
  end
27
69
  end
28
70
  }
29
-
71
+
30
72
  #puts "data: " + data.to_s
31
73
  #puts "data_string: " + data_string
32
74
  #puts "data_string_param: " + data_string_param
33
-
75
+
34
76
  @driver.operaDesktopAction(action_name, data, data_string, data_string_param)
35
77
  end
36
78
 
@@ -39,56 +81,69 @@ private
39
81
  opts.each { |mod| list << KEYMODIFIER_ENUM_MAP[mod] }
40
82
  driver.keyPress(key, list)
41
83
  end
42
-
43
- def key_down(key, *opts)
84
+
85
+ def key_down_direct(key, *opts)
44
86
  list = Java::JavaUtil::ArrayList.new
45
87
  opts.each { |mod| list << KEYMODIFIER_ENUM_MAP[mod] }
46
88
  driver.keyDown(key, list)
47
89
  end
48
-
49
- def key_up(key, *opts)
90
+
91
+ def key_up_direct(key, *opts)
50
92
  list = Java::JavaUtil::ArrayList.new
51
93
  opts.each { |mod| list << KEYMODIFIER_ENUM_MAP[mod] }
52
94
  driver.keyUp(key, list)
53
95
  end
54
-
96
+
55
97
  # Private wait functions
56
98
  #
57
99
  def wait_start
58
100
  driver.waitStart()
59
101
  end
60
-
102
+
61
103
  def wait_for_window_shown(win_name = "")
62
104
  driver.waitForWindowShown(win_name)
63
105
  end
64
-
106
+
65
107
  def wait_for_window_updated(win_name = "")
66
108
  driver.waitForWindowUpdated(win_name)
67
109
  end
68
-
110
+
69
111
  def wait_for_window_activated(win_name = "")
70
112
  driver.waitForWindowActivated(win_name)
71
113
  end
72
-
114
+
73
115
  def wait_for_window_close(win_name = "")
74
116
  driver.waitForWindowClose(win_name)
75
117
  end
76
-
118
+
77
119
  def wait_for_window_loaded(win_name = "")
78
120
  win_id = driver.waitForWindowLoaded(win_name)
79
121
  # Hack to allow for Javascript focus events and the like
80
- # We need to increase this until we have fixed the bug with the
122
+ # We need to increase this until we have fixed the bug with the
81
123
  # tab title taking extra time to change
82
124
  sleep(0.5)
83
125
  win_id
84
126
  end
85
-
127
+
128
+ def wait_for_menu_shown(menu_name = "")
129
+ driver.waitForMenuShown(menu_name)
130
+ end
131
+
132
+ def wait_for_menu_closed(menu_name = "")
133
+ driver.waitForMenuClosed(menu_name)
134
+ end
135
+
136
+ def wait_for_widget_visible
137
+ i = 15
138
+ sleep(0.1) while element(true).isVisible == false and (i -= 1) > 0
139
+ end
140
+
86
141
  def wait_for_widget_enabled
87
142
  max_timeout = 1.5
88
143
  curr_timeout = 0.0
89
144
  step = 0.1
90
-
91
- while curr_timeout < max_timeout
145
+
146
+ while curr_timeout < max_timeout
92
147
  if element(true).isEnabled == true
93
148
  break
94
149
  end
@@ -96,14 +151,24 @@ private
96
151
  sleep(step)
97
152
  curr_timeout += step
98
153
  end
99
-
154
+
100
155
  # Check we didn't exceed the timeout
101
156
  if curr_timeout >= max_timeout
102
157
  return false
103
158
  end
104
-
159
+
105
160
  # Return true
106
161
  true
107
162
  end
163
+
164
+ def mac_internal?
165
+ Config::CONFIG['target_os'] == "darwin"
166
+ end
167
+
168
+ def linux_internal?
169
+ Config::CONFIG['target_os'] == "linux"
170
+ end
171
+
172
+
108
173
  end
109
174
  end
@@ -1,6 +1,6 @@
1
1
  module OperaWatir
2
2
  module DesktopContainer
3
-
3
+
4
4
  ######################################################################
5
5
  # Method for accessing a button element
6
6
  #
@@ -8,20 +8,21 @@ module OperaWatir
8
8
  # browser.quick_button(:name, "button_OK")
9
9
  #
10
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
11
+ # @param [String] what Search text to find the element with. Currently name, text or string_id
12
+ # of the button
13
13
  #
14
14
  # @return [Object] button object if found, otherwise nil
15
15
  #
16
16
  def quick_button(how, what)
17
- if how == :pos
18
- if what.is_a? Fixnum
19
- what = [0, what]
20
- end
21
- end
17
+ what = [0, what] if how == :pos && (what.is_a? Fixnum)
18
+ #if how == :pos
19
+ # if what.is_a? Fixnum
20
+ # what = [0, what]
21
+ # end
22
+ #end
22
23
  QuickButton.new(self, how, what, parent_widget, window_id, :button)
23
24
  end
24
-
25
+
25
26
  ######################################################################
26
27
  # Method for accessing a tab button element
27
28
  #
@@ -43,7 +44,7 @@ module OperaWatir
43
44
  end
44
45
  QuickTab.new(self, how, what, parent_widget, window_id, :tabbutton)
45
46
  end
46
-
47
+
47
48
  ######################################################################
48
49
  # Method for accessing a checkbox element
49
50
  #
@@ -51,7 +52,7 @@ module OperaWatir
51
52
  # browser.quick_checkbox(:name, "Enable_wand_checkbox")
52
53
  #
53
54
  # @param [String] how Method to find the element. :name, :text or :string_id
54
- # @param [String] what Search text to find element with.
55
+ # @param [String] what Search text to find element with.
55
56
  #
56
57
  # @return [Object] checkbox object if found, otherwise nil
57
58
  #
@@ -65,8 +66,8 @@ module OperaWatir
65
66
  # @example
66
67
  # browser.quick_dialogtab(:name, "tab_prefs_forms")
67
68
  #
68
- # @param [String] how Method to find the element. :name, :string_id or :text
69
- # @param [String] what Search text to find the element with.
69
+ # @param [String] how Method to find the element. :name, :string_id or :text
70
+ # @param [String] what Search text to find the element with.
70
71
  #
71
72
  # @return [Object] dialog tab object if found, otherwise nil
72
73
  #
@@ -81,7 +82,7 @@ module OperaWatir
81
82
  # browser.quick_dropdown(:name, "Startup_mode_dropdown")
82
83
  #
83
84
  # @param [String] how Method to find the element. :name, :string_id or :text
84
- # @param [String] what Search text to find the element with.
85
+ # @param [String] what Search text to find the element with.
85
86
  #
86
87
  # @return [Object] drop down object if found, otherwise nil
87
88
  #
@@ -89,6 +90,22 @@ module OperaWatir
89
90
  QuickDropdown.new(self, how, what, parent_widget, window_id, :dropdown)
90
91
  end
91
92
 
93
+ ######################################################################
94
+ # Method for accessing a combobox (i.e. dropdown) element
95
+ #
96
+ # @example
97
+ # browser.quick_dropdown(:name, "Startup_mode_dropdown")
98
+ #
99
+ # @param [String] how Method to find the element. :name, :string_id or :text
100
+ # @param [String] what Search text to find the element with.
101
+ #
102
+ # @return [Object] drop down object if found, otherwise nil
103
+ #
104
+ def quick_dropdownitem(how, what)
105
+ QuickDropdownItem.new(self, how, what, parent_widget, window_id, :dropdownitem)
106
+ end
107
+
108
+
92
109
  ######################################################################
93
110
  # Method for accessing a quickfind element
94
111
  #
@@ -96,7 +113,7 @@ module OperaWatir
96
113
  # browser.quick_find(:name, "Filetypes_quickfind")
97
114
  #
98
115
  # @param [String] how Method to find the element. :name, :string_id or :text
99
- # @param [String] what Search text to find the element with.
116
+ # @param [String] what Search text to find the element with.
100
117
  #
101
118
  # @return [Object] quickfind object if found, otherwise nil
102
119
  #
@@ -111,7 +128,7 @@ module OperaWatir
111
128
  # browser.quick_editfield(:name, "Startpage_edit")
112
129
  #
113
130
  # @param [String] how Method to find the element. :name, :string_id or :text
114
- # @param [String] what Search text to find the element with.
131
+ # @param [String] what Search text to find the element with.
115
132
  #
116
133
  # @return [Object] edit field object if found, otherwise nil
117
134
  #
@@ -126,7 +143,7 @@ module OperaWatir
126
143
  # browser.quick_label(:name, "label_for_Popups_dropdown")
127
144
  #
128
145
  # @param [String] how Method to find the element. :name, :string_id or :text
129
- # @param [String] what Search text to find the element with.
146
+ # @param [String] what Search text to find the element with.
130
147
  #
131
148
  # @return [Object] label object if found, otherwise nil
132
149
  #
@@ -141,7 +158,7 @@ module OperaWatir
141
158
  # browser.quick_radiobutton(:name, "Accept_cookies_radio")
142
159
  #
143
160
  # @param [String] how Method to find the element. :name, :string_id or :text
144
- # @param [String] what Search text to find the element with.
161
+ # @param [String] what Search text to find the element with.
145
162
  #
146
163
  # @return [Object] radio button object if found, otherwise nil
147
164
  #
@@ -156,14 +173,14 @@ module OperaWatir
156
173
  # browser.quick_treeview(:name, "Web_search_treeview")
157
174
  #
158
175
  # @param [String] how Method to find the element. :name, :string_id or :text
159
- # @param [String] what Search text to find the element with.
176
+ # @param [String] what Search text to find the element with.
160
177
  #
161
178
  # @return [Object] treeview object if found, otherwise nil
162
179
  #
163
180
  def quick_treeview(how, what)
164
181
  QuickTreeView.new(self, how, what, parent_widget, window_id, :treeview)
165
182
  end
166
-
183
+
167
184
  ######################################################################
168
185
  # Method for accessing an addressfield object
169
186
  #
@@ -171,14 +188,14 @@ module OperaWatir
171
188
  # browser.quick_toolbar(:name, "Document Toolbar").quick_addressfield(:name, "tba_addressfield")
172
189
  #
173
190
  # @param [String] how Method to find the element. :name, :string_id or :text
174
- # @param [String] what Search text to find the element with.
191
+ # @param [String] what Search text to find the element with.
175
192
  #
176
193
  # @return [Object] addressfield object if found, otherwise nil
177
194
  #
178
195
  def quick_addressfield(how, what)
179
196
  QuickAddressField.new(self, how, what, parent_widget, window_id, :addressfield)
180
197
  end
181
-
198
+
182
199
  ######################################################################
183
200
  # Method for accessing a searchfield element
184
201
  #
@@ -186,14 +203,14 @@ module OperaWatir
186
203
  # browser.quick_searchfield(:name, "Web_search_searchfield")
187
204
  #
188
205
  # @param [String] how Method to find the element. :name, :string_id or :text
189
- # @param [String] what Search text to find the element with.
206
+ # @param [String] what Search text to find the element with.
190
207
  #
191
208
  # @return [Object] searchfield object if found, otherwise nil
192
209
  #
193
210
  def quick_searchfield(how, what)
194
211
  QuickSearchField.new(self, how, what, parent_widget, window_id, :search)
195
212
  end
196
-
213
+
197
214
  ######################################################################
198
215
  # Method for accessing a toolbar element
199
216
  #
@@ -201,14 +218,14 @@ module OperaWatir
201
218
  # browser.quick_toolbar(:name, "Document_toolbar")
202
219
  #
203
220
  # @param [String] how Method to find the element. :name, :string_id or :text
204
- # @param [String] what Search text to find the element with.
221
+ # @param [String] what Search text to find the element with.
205
222
  #
206
223
  # @return [Object] toolbar object if found, otherwise nil
207
224
  #
208
225
  def quick_toolbar(how, what)
209
226
  QuickToolbar.new(self, how, what, parent_widget, window_id, :toolbar)
210
227
  end
211
-
228
+
212
229
  ######################################################################
213
230
  # Method for accessing a tree item in a treeview
214
231
  #
@@ -216,7 +233,7 @@ module OperaWatir
216
233
  # browser.quick_treeview(:name, "Server_treeview").quick_treeitem(:pos, [2,0])
217
234
  #
218
235
  # @param [String] how Method to find the element. :name, :string_id or :text
219
- # @param [String] what Search text to find the element with. Text or position
236
+ # @param [String] what Search text to find the element with. Text or position
220
237
  # of treeitem. Position is specified as [row, column]
221
238
  #
222
239
  # @return [Object] treeitem object if found, otherwise nil
@@ -232,7 +249,7 @@ module OperaWatir
232
249
  # browser.quick_gridlayout(:name, "RulesGrid").quick_griditem(:name, "GridItem0").quick_editfield(:name, "Match")
233
250
  #
234
251
  # @param [String] how Method to find the element. :name, :string_id or :text
235
- # @param [String] what Search text to find the element with. Text or position
252
+ # @param [String] what Search text to find the element with. Text or position
236
253
  # of treeitem. Position is specified as [row, column]
237
254
  #
238
255
  # @return [Object] griditem object if found, otherwise nil
@@ -242,14 +259,14 @@ module OperaWatir
242
259
  end
243
260
 
244
261
  ######################################################################
245
- # Method for accessing a grid layout
246
- # (A grid layout would normally be used to specify the path to a child item in one of its cells.
262
+ # Method for accessing a grid layout
263
+ # (A grid layout would normally be used to specify the path to a child item in one of its cells.
247
264
  #
248
265
  # @example (The label dialog for mail labels)
249
266
  # browser.quick_gridlayout(:name, "RulesGrid").quick_griditem(:name, "GridItem0").quick_editfield(:name, "Match")
250
267
  #
251
268
  # @param [String] how Method to find the element. :name, :string_id or :text
252
- # @param [String] what Search text to find the element with. Text or position
269
+ # @param [String] what Search text to find the element with. Text or position
253
270
  # of treeitem. Position is specified as [row, column]
254
271
  #
255
272
  # @return [Object] gridlayout object if found, otherwise nil
@@ -258,7 +275,7 @@ module OperaWatir
258
275
  QuickGridLayout.new(self, how, what, parent_widget, window_id, :gridlayout)
259
276
  end
260
277
 
261
-
278
+
262
279
  ######################################################################
263
280
  # Method for accessing a thumbnail (speeddial, thumbnail when hovering tab groups)
264
281
  #
@@ -267,7 +284,7 @@ module OperaWatir
267
284
  # browser.quick_thumbnail(:name, "Speed Dial 2")
268
285
  #
269
286
  # @param [String] how Method to find the element. :name, :string_id or :text
270
- # @param [String] what Search text to find the element with. Text or position
287
+ # @param [String] what Search text to find the element with. Text or position
271
288
  # of treeitem. Position is specified as [row, column]
272
289
  #
273
290
  # @return [Object] thumbnail object if found, otherwise nil
@@ -292,7 +309,7 @@ module OperaWatir
292
309
  # @param [String] how Method to find the element. Currently only :name is supported
293
310
  # @param [String] what or [int] window_id Search text to find the element with. Name of window
294
311
  # or the windows window_id
295
- #
312
+ #
296
313
  #
297
314
  # @return [Object] window object if found, otherwise nil
298
315
  #
@@ -300,6 +317,58 @@ module OperaWatir
300
317
  QuickWindow.new(self, how, what)
301
318
  end
302
319
 
320
+ ##########################################################################
321
+ # Method for accessing a menu
322
+ #
323
+ # @example
324
+ # browser.quick_menu(:name, "Main Menu")
325
+ #
326
+ # @param [String] how Method to find the element. Supported: :name
327
+ # @param [String] what Search text to find the element with.
328
+ #
329
+ def quick_menu(how, what)
330
+ if mac_internal?
331
+ QuickMenu.new(self, how, what, nil)
332
+ else
333
+ QuickMenu.new(self, how, what, window_id)
334
+ end
335
+ end
336
+
337
+ #############################################################################
338
+ # Method for accessing a menuitem
339
+ #
340
+ # @example
341
+ # browser.quick_menu(:name, "Main Menu").quick_menuitem(:submenu, "Browser Tools Menu")
342
+ # browser.quick_menuitem(:name, "Browser File Menu")
343
+ # browser.quick_menuitem(:action, "Open page")
344
+ # browser.quick_menuitem(:name, "Open link, vg.no")
345
+ # browser.quick_menuitem(:string_id, "SOME_STRING_ID")
346
+ # browser.quick_menu(:name, "Main Menu").quick_menuitem(:acckey, "b")
347
+ # browser.quick_menu(:name, "Edit Item Popup Menu").quick_menuitem(:pos, 2)
348
+ #
349
+ #
350
+ # @param [String] how Method to find the element. Supported: name, text, string_id, action
351
+ # submenu, pos, acckey, shortcut.
352
+ # The item name is:
353
+ # - if the item has an action, the action
354
+ # - if the item has an action with a parameter; "<action>, <actionparameter>"
355
+ # - else if the item opens a submenu, the submenuname
356
+ #
357
+ # An acckey and pos are unique only within a given menu, so in this case
358
+ # the accesspath to specify the item should include the menu
359
+ #
360
+ #
361
+ # Note that only methods that identify a unique item gives a predictable result
362
+ # @param [String] what Search text to find element with
363
+ #
364
+ def quick_menuitem(how, what)
365
+ if mac_internal? || (window_id != nil && window_id <= 0)
366
+ QuickMenuItem.new(self, how, what, name == 'Opera' ? nil : name)
367
+ else
368
+ QuickMenuItem.new(self, how, what, window_id)
369
+ end
370
+ end
371
+
303
372
  end
304
373
  end
305
374