operawatir 0.4-jruby → 0.4.1-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 (222) hide show
  1. data/.gitmodules +3 -3
  2. data/AUTHORS +1 -0
  3. data/CHANGES +454 -0
  4. data/README.md +67 -50
  5. data/Rakefile +6 -10
  6. data/VERSION +1 -1
  7. data/bin/desktopwatir +52 -29
  8. data/bin/operawatir +50 -18
  9. data/lib/operadriver/client-combined-nodeps.jar +0 -0
  10. data/lib/operadriver/webdriver-opera.jar +0 -0
  11. data/lib/operawatir.rb +8 -1
  12. data/lib/operawatir/browser.rb +35 -15
  13. data/lib/operawatir/collection.rb +2 -2
  14. data/lib/operawatir/compat.rb +3 -2
  15. data/lib/operawatir/compat/browser.rb +0 -5
  16. data/lib/operawatir/compat/collection.rb +15 -0
  17. data/lib/operawatir/compat/element.rb +72 -21
  18. data/lib/operawatir/compat/element_finders.rb +6 -0
  19. data/lib/operawatir/compat/selector.rb +7 -0
  20. data/lib/operawatir/compat/window.rb +49 -0
  21. data/lib/operawatir/desktop_browser.rb +88 -14
  22. data/lib/operawatir/desktop_common.rb +0 -2
  23. data/lib/operawatir/desktop_container.rb +82 -29
  24. data/lib/operawatir/desktop_helper.rb +2 -0
  25. data/lib/operawatir/element.rb +49 -25
  26. data/lib/operawatir/helper.rb +5 -3
  27. data/lib/operawatir/keys.rb +19 -6
  28. data/lib/operawatir/preferences.rb +315 -78
  29. data/lib/operawatir/quickwidgets.rb +2 -1
  30. data/lib/operawatir/quickwidgets/quick_addressfield.rb +12 -0
  31. data/lib/operawatir/quickwidgets/quick_button.rb +8 -2
  32. data/lib/operawatir/quickwidgets/quick_checkbox.rb +5 -5
  33. data/lib/operawatir/quickwidgets/quick_editfield.rb +8 -5
  34. data/lib/operawatir/quickwidgets/quick_find.rb +11 -0
  35. data/lib/operawatir/quickwidgets/quick_griditem.rb +11 -0
  36. data/lib/operawatir/quickwidgets/quick_gridlayout.rb +11 -0
  37. data/lib/operawatir/quickwidgets/quick_searchfield.rb +7 -1
  38. data/lib/operawatir/quickwidgets/quick_tab.rb +0 -1
  39. data/lib/operawatir/quickwidgets/quick_treeitem.rb +22 -1
  40. data/lib/operawatir/quickwidgets/quick_widget.rb +62 -23
  41. data/lib/operawatir/quickwidgets/quick_window.rb +32 -2
  42. data/lib/operawatir/screenshot.rb +46 -0
  43. data/lib/operawatir/version.rb +6 -4
  44. data/lib/operawatir/window.rb +53 -67
  45. data/operawatir.gemspec +310 -245
  46. data/spec/operawatir/README.md +4 -0
  47. data/spec/operawatir/core/browser_spec.rb +82 -0
  48. data/spec/operawatir/core/element_spec.rb +88 -0
  49. data/spec/operawatir/core/preferences_spec.rb +438 -0
  50. data/spec/operawatir/core/screenshot_spec.rb +76 -0
  51. data/spec/{new_watirspec → operawatir/core}/spatnav_spec.rb +3 -3
  52. data/spec/operawatir/core/window_spec.rb +76 -0
  53. data/spec/operawatir/desktop/desktopbrowser_spec.rb +316 -0
  54. data/spec/operawatir/desktop/quickaddressfield_spec.rb +59 -0
  55. data/spec/operawatir/desktop/quickbutton_spec.rb +248 -0
  56. data/spec/operawatir/desktop/quickcheckbox_spec.rb +36 -0
  57. data/spec/operawatir/desktop/quickdialogtab_spec.rb +30 -0
  58. data/spec/operawatir/desktop/quickdropdown_spec.rb +39 -0
  59. data/spec/operawatir/desktop/quickeditfield_spec.rb +51 -0
  60. data/spec/operawatir/desktop/quickfind_spec.rb +30 -0
  61. data/spec/operawatir/desktop/quickgriditem_spec.rb +16 -0
  62. data/spec/operawatir/desktop/quickgridlayout_spec.rb +15 -0
  63. data/spec/operawatir/desktop/quicklabel_spec.rb +28 -0
  64. data/spec/operawatir/desktop/quickradiobutton_spec.rb +24 -0
  65. data/spec/operawatir/desktop/quicksearchfield_spec.rb +26 -0
  66. data/spec/operawatir/desktop/quicktab_spec.rb +86 -0
  67. data/spec/operawatir/desktop/quickthumbnail_spec.rb +37 -0
  68. data/spec/operawatir/desktop/quicktreeitem_spec.rb +135 -0
  69. data/spec/operawatir/desktop/quicktreeview_spec.rb +30 -0
  70. data/spec/operawatir/desktop/quickwidget_spec.rb +101 -0
  71. data/spec/operawatir/desktop/quickwindow_spec.rb +108 -0
  72. data/spec/operawatir/desktop/shared/shared.rb +138 -0
  73. data/spec/operawatir/fixtures/boxes.html +22 -0
  74. data/spec/operawatir/fixtures/browsers.svg +367 -0
  75. data/spec/operawatir/fixtures/frames.html +13 -0
  76. data/spec/operawatir/fixtures/grid.html +29 -0
  77. data/spec/operawatir/fixtures/input_fields_value.html +6 -0
  78. data/spec/operawatir/fixtures/onclick.html +20 -0
  79. data/spec/operawatir/fixtures/paragraphs.html +15 -0
  80. data/spec/operawatir/fixtures/two_input_fields.html +6 -0
  81. data/spec/{new_watirspec → operawatir}/guards.rb +0 -0
  82. data/spec/operawatir/matchers.rb +68 -0
  83. data/spec/{legacy_watirspec → operawatir}/server.rb +0 -0
  84. data/spec/operawatir/watirspec.rake +43 -0
  85. data/spec/operawatir/watirspec_desktophelper.rb +14 -0
  86. data/spec/operawatir/watirspec_helper.rb +62 -0
  87. data/spec/{legacy_watirspec → watir2}/area_spec.rb +0 -0
  88. data/spec/{legacy_watirspec → watir2}/areas_spec.rb +0 -0
  89. data/spec/{legacy_watirspec → watir2}/browser_spec.rb +2 -0
  90. data/spec/{legacy_watirspec → watir2}/button_spec.rb +0 -0
  91. data/spec/{legacy_watirspec → watir2}/buttons_spec.rb +0 -0
  92. data/spec/{legacy_watirspec → watir2}/checkbox_spec.rb +0 -0
  93. data/spec/{legacy_watirspec → watir2}/checkboxes_spec.rb +0 -0
  94. data/spec/{legacy_watirspec → watir2}/collections_spec.rb +0 -0
  95. data/spec/{legacy_watirspec → watir2}/dd_spec.rb +0 -0
  96. data/spec/{legacy_watirspec → watir2}/dds_spec.rb +0 -0
  97. data/spec/{legacy_watirspec → watir2}/del_spec.rb +0 -0
  98. data/spec/{legacy_watirspec → watir2}/dels_spec.rb +0 -0
  99. data/spec/{legacy_watirspec → watir2}/div_spec.rb +0 -0
  100. data/spec/{legacy_watirspec → watir2}/divs_spec.rb +0 -0
  101. data/spec/{legacy_watirspec → watir2}/dl_spec.rb +0 -0
  102. data/spec/{legacy_watirspec → watir2}/dls_spec.rb +0 -0
  103. data/spec/{legacy_watirspec → watir2}/dt_spec.rb +0 -0
  104. data/spec/{legacy_watirspec → watir2}/dts_spec.rb +0 -0
  105. data/spec/watir2/element_spec.rb +155 -0
  106. data/spec/{legacy_watirspec → watir2}/em_spec.rb +0 -0
  107. data/spec/{legacy_watirspec → watir2}/ems_spec.rb +0 -0
  108. data/spec/{legacy_watirspec → watir2}/filefield_spec.rb +0 -0
  109. data/spec/{legacy_watirspec → watir2}/filefields_spec.rb +0 -0
  110. data/spec/{legacy_watirspec → watir2}/fixtures/2000_spans.html +0 -0
  111. data/spec/{legacy_watirspec → watir2}/fixtures/bug_duplicate_attributes.html +0 -0
  112. data/spec/{legacy_watirspec → watir2}/fixtures/bug_javascript_001.html +0 -0
  113. data/spec/{legacy_watirspec → watir2}/fixtures/buttons_with_duplicate_ids.html +0 -0
  114. data/spec/{legacy_watirspec → watir2}/fixtures/collections.html +0 -0
  115. data/spec/{legacy_watirspec → watir2}/fixtures/definition_lists.html +0 -0
  116. data/spec/{legacy_watirspec → watir2}/fixtures/euc-jp_text.html +0 -0
  117. data/spec/{legacy_watirspec → watir2}/fixtures/forms_with_input_elements.html +0 -0
  118. data/spec/{legacy_watirspec → watir2}/fixtures/frame_1.html +0 -0
  119. data/spec/{legacy_watirspec → watir2}/fixtures/frame_2.html +0 -0
  120. data/spec/{legacy_watirspec → watir2}/fixtures/frames.html +0 -0
  121. data/spec/{legacy_watirspec → watir2}/fixtures/iframes.html +0 -0
  122. data/spec/{legacy_watirspec → watir2}/fixtures/images.html +0 -0
  123. data/spec/{legacy_watirspec → watir2}/fixtures/images/1.gif +0 -0
  124. data/spec/{legacy_watirspec → watir2}/fixtures/images/2.gif +0 -0
  125. data/spec/{legacy_watirspec → watir2}/fixtures/images/3.gif +0 -0
  126. data/spec/{legacy_watirspec → watir2}/fixtures/images/button.jpg +0 -0
  127. data/spec/{legacy_watirspec → watir2}/fixtures/images/circle.jpg +0 -0
  128. data/spec/{legacy_watirspec → watir2}/fixtures/images/map.gif +0 -0
  129. data/spec/{legacy_watirspec → watir2}/fixtures/images/map2.gif +0 -0
  130. data/spec/{legacy_watirspec → watir2}/fixtures/images/minus.gif +0 -0
  131. data/spec/{legacy_watirspec → watir2}/fixtures/images/originaltriangle.jpg +0 -0
  132. data/spec/{legacy_watirspec → watir2}/fixtures/images/plus.gif +0 -0
  133. data/spec/{legacy_watirspec → watir2}/fixtures/images/square.jpg +0 -0
  134. data/spec/{legacy_watirspec → watir2}/fixtures/images/triangle.jpg +0 -0
  135. data/spec/{legacy_watirspec → watir2}/fixtures/iso-2022-jp_text.html +0 -0
  136. data/spec/{legacy_watirspec → watir2}/fixtures/javascript/helpers.js +0 -0
  137. data/spec/{legacy_watirspec → watir2}/fixtures/jquery.html +0 -0
  138. data/spec/{legacy_watirspec → watir2}/fixtures/latin1_text.html +0 -0
  139. data/spec/{legacy_watirspec → watir2}/fixtures/multiple_ids.html +0 -0
  140. data/spec/{legacy_watirspec → watir2}/fixtures/non_control_elements.html +0 -0
  141. data/spec/{legacy_watirspec → watir2}/fixtures/parser_bug_001.html +0 -0
  142. data/spec/{legacy_watirspec → watir2}/fixtures/prevent_form_submit.html +0 -0
  143. data/spec/{legacy_watirspec → watir2}/fixtures/right_click.html +0 -0
  144. data/spec/{legacy_watirspec → watir2}/fixtures/shift_jis_text.html +0 -0
  145. data/spec/{legacy_watirspec → watir2}/fixtures/tables.html +0 -0
  146. data/spec/{legacy_watirspec → watir2}/fixtures/timeout.html +0 -0
  147. data/spec/{legacy_watirspec → watir2}/fixtures/timeout_window_location.html +0 -0
  148. data/spec/{legacy_watirspec → watir2}/fixtures/tiny_mce.html +0 -0
  149. data/spec/{legacy_watirspec → watir2}/fixtures/utf8_text.html +0 -0
  150. data/spec/{legacy_watirspec → watir2}/fixtures/watirspec.css +0 -0
  151. data/spec/{legacy_watirspec → watir2}/form_spec.rb +0 -0
  152. data/spec/{legacy_watirspec → watir2}/forms_spec.rb +0 -0
  153. data/spec/{legacy_watirspec → watir2}/frame_spec.rb +0 -0
  154. data/spec/{legacy_watirspec → watir2}/frames_spec.rb +0 -0
  155. data/spec/{legacy_watirspec → watir2}/guards.rb +0 -0
  156. data/spec/{legacy_watirspec → watir2}/hidden_spec.rb +0 -0
  157. data/spec/{legacy_watirspec → watir2}/hiddens_spec.rb +0 -0
  158. data/spec/{legacy_watirspec → watir2}/hn_spec.rb +0 -0
  159. data/spec/{legacy_watirspec → watir2}/hns_spec.rb +0 -0
  160. data/spec/{legacy_watirspec → watir2}/image_spec.rb +0 -0
  161. data/spec/{legacy_watirspec → watir2}/images_spec.rb +0 -0
  162. data/spec/{legacy_watirspec → watir2}/ins_spec.rb +0 -0
  163. data/spec/{legacy_watirspec → watir2}/inses_spec.rb +0 -0
  164. data/spec/{legacy_watirspec → watir2}/label_spec.rb +0 -0
  165. data/spec/{legacy_watirspec → watir2}/labels_spec.rb +0 -0
  166. data/spec/{legacy_watirspec → watir2}/li_spec.rb +0 -0
  167. data/spec/{legacy_watirspec → watir2}/link_spec.rb +0 -0
  168. data/spec/{legacy_watirspec → watir2}/links_spec.rb +0 -0
  169. data/spec/{legacy_watirspec → watir2}/lis_spec.rb +0 -0
  170. data/spec/{legacy_watirspec → watir2}/map_spec.rb +0 -0
  171. data/spec/{legacy_watirspec → watir2}/maps_spec.rb +0 -0
  172. data/spec/{legacy_watirspec → watir2}/meta_spec.rb +0 -0
  173. data/spec/{legacy_watirspec → watir2}/metas_spec.rb +0 -0
  174. data/spec/{legacy_watirspec → watir2}/ol_spec.rb +0 -0
  175. data/spec/{legacy_watirspec → watir2}/ols_spec.rb +0 -0
  176. data/spec/{legacy_watirspec → watir2}/option_spec.rb +0 -0
  177. data/spec/{legacy_watirspec → watir2}/p_spec.rb +0 -0
  178. data/spec/{legacy_watirspec → watir2}/pre_spec.rb +0 -0
  179. data/spec/{legacy_watirspec → watir2}/pres_spec.rb +0 -0
  180. data/spec/{legacy_watirspec → watir2}/ps_spec.rb +0 -0
  181. data/spec/{legacy_watirspec → watir2}/radio_spec.rb +0 -0
  182. data/spec/{legacy_watirspec → watir2}/radios_spec.rb +0 -0
  183. data/spec/{legacy_watirspec → watir2}/select_list_spec.rb +84 -71
  184. data/spec/{legacy_watirspec → watir2}/select_lists_spec.rb +0 -0
  185. data/spec/{new_watirspec → watir2}/server.rb +0 -0
  186. data/spec/{legacy_watirspec → watir2}/span_spec.rb +0 -0
  187. data/spec/{legacy_watirspec → watir2}/spans_spec.rb +0 -0
  188. data/spec/{legacy_watirspec → watir2}/spec_helper.rb +0 -0
  189. data/spec/{legacy_watirspec → watir2}/strong_spec.rb +0 -0
  190. data/spec/{legacy_watirspec → watir2}/strongs_spec.rb +0 -0
  191. data/spec/{legacy_watirspec → watir2}/table_bodies_spec.rb +0 -0
  192. data/spec/{legacy_watirspec → watir2}/table_body_spec.rb +0 -0
  193. data/spec/{legacy_watirspec → watir2}/table_cell_spec.rb +0 -0
  194. data/spec/{legacy_watirspec → watir2}/table_cells_spec.rb +0 -0
  195. data/spec/{legacy_watirspec → watir2}/table_footer_spec.rb +0 -0
  196. data/spec/{legacy_watirspec → watir2}/table_footers_spec.rb +0 -0
  197. data/spec/{legacy_watirspec → watir2}/table_header_spec.rb +0 -0
  198. data/spec/{legacy_watirspec → watir2}/table_headers_spec.rb +0 -0
  199. data/spec/{legacy_watirspec → watir2}/table_row_spec.rb +0 -0
  200. data/spec/{legacy_watirspec → watir2}/table_rows_spec.rb +0 -0
  201. data/spec/{legacy_watirspec → watir2}/table_spec.rb +0 -0
  202. data/spec/{legacy_watirspec → watir2}/tables_spec.rb +0 -0
  203. data/spec/{legacy_watirspec → watir2}/text_field_spec.rb +0 -0
  204. data/spec/{legacy_watirspec → watir2}/text_fields_spec.rb +0 -0
  205. data/spec/{legacy_watirspec → watir2}/ul_spec.rb +0 -0
  206. data/spec/{legacy_watirspec → watir2}/uls_spec.rb +0 -0
  207. data/spec/{legacy_watirspec → watir2}/watir_compatibility_spec.rb +0 -0
  208. data/spec/{legacy_watirspec → watir2}/watirspec_helper.rb +0 -0
  209. data/spec/{new_watirspec → watir3}/browser_spec.rb +11 -21
  210. data/spec/{new_watirspec → watir3}/clipboard_spec.rb +2 -2
  211. data/spec/{new_watirspec → watir3}/collection_spec.rb +0 -0
  212. data/spec/{new_watirspec → watir3}/element_spec.rb +30 -12
  213. data/spec/watir3/guards.rb +39 -0
  214. data/spec/{new_watirspec → watir3}/keys_spec.rb +0 -0
  215. data/spec/watir3/server.rb +91 -0
  216. data/spec/{new_watirspec → watir3}/watirspec_helper.rb +0 -0
  217. data/spec/{new_watirspec → watir3}/window_spec.rb +8 -83
  218. metadata +315 -280
  219. data/lib/operadriver/selenium-common.jar +0 -0
  220. data/spec/legacy_watirspec/element_spec.rb +0 -86
  221. data/spec/new_watirspec/preferences_spec.rb +0 -144
  222. data/spec/new_watirspec/screenshot_spec.rb +0 -34
@@ -1,27 +1,76 @@
1
1
  module OperaWatir
2
2
  module Compat
3
3
  module Window
4
+ include Deprecated
4
5
 
6
+ #
5
7
  # Checks whether the body has the given text in it.
6
8
  #
7
9
  # @param [String] str Text to search for.
8
10
  # @return [Boolean] true if the body contains the given text,
9
11
  # false otherwise
12
+ #
13
+
10
14
  def contains_text(str)
11
15
  text.index(str)
12
16
  end
13
17
 
18
+
19
+ #
14
20
  # Find elements that match the given XPath.
15
21
  #
16
22
  # @param [String] value The XPath expression to search for.
17
23
  # @return [OperaWatir::Collection] A collection of matching
18
24
  # elements.
25
+ #
26
+
19
27
  def elements_by_xpath(value)
20
28
  find_by_xpath(value)
21
29
  end
22
30
 
23
31
  alias_method :element_by_xpath, :elements_by_xpath
24
32
 
33
+
34
+ #
35
+ # Opera specific
36
+ #
37
+
38
+ def get_hash
39
+ visual_hash
40
+ end
41
+
42
+ deprecated :get_hash, 'browser.visual_hash'
43
+
44
+
45
+ #
46
+ # TODO This is a relic from the old OperaWatir implementation,
47
+ # tests should be updated.
48
+ #
49
+
50
+ def frame(selector, argument)
51
+ case selector
52
+ when :name
53
+ driver.switch_to.frame(argument)
54
+ when :index
55
+ driver.switch_to.frame(argument.to_i - 1) # index starts from 1 in Watir
56
+ else
57
+ raise OperaWatir::Exceptions::NotImplementedException,
58
+ "We do not support the `#{selector}' selector yet"
59
+ end
60
+ end
61
+
62
+
63
+ def switch_to_default
64
+ driver.switch_to.default_content
65
+ end
66
+
67
+
68
+ def show_frames
69
+ frames = driver.list_frames
70
+ puts "There are #{frames.length.to_s} frames"
71
+ frames.each_with_index { |frame, i| puts "frame index: #{(i.to_i + 1).to_s} name: #{frame.to_s}" }
72
+ end
73
+
25
74
  end
26
75
  end
27
76
  end
@@ -3,16 +3,19 @@ module OperaWatir
3
3
  include DesktopContainer
4
4
  include DesktopCommon
5
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"]
6
+ LoadActions = ["Open url in new page", "Open url in current page", "Open url in new background page",
7
+ "Open url in new window", "New private page", "Paste and go", "Paste and go background",
8
+ "Hotclick search", "Duplicate page", "Reopen page", "Back", "Forward", "Help"]
9
9
 
10
10
  # @private
11
11
  def initialize
12
- OperaWatir.compatibility! unless OperaWatir.api >= 2
12
+ OperaWatir.compatibility! unless OperaWatir.api >= 3
13
13
 
14
14
  self.driver = OperaDesktopDriver.new(self.class.opera_driver_settings)
15
15
  self.active_window = OperaWatir::Window.new(self)
16
+ self.preferences = OperaWatir::Preferences.new(self)
17
+ self.keys = OperaWatir::Keys.new(self)
18
+ self.spatnav = OperaWatir::Spatnav.new(self)
16
19
  end
17
20
 
18
21
  # @private
@@ -20,10 +23,10 @@ module OperaWatir
20
23
  # dialogs to autoclose in Dialog.cpp when then OnUrlChanged is fired
21
24
  # after a dialog is opened
22
25
  def goto(url = "")
23
- super #active_window.url = url
26
+ active_window.url = url
24
27
  sleep(1)
25
28
  end
26
-
29
+
27
30
  ######################################################################
28
31
  # Quits Opera
29
32
  #
@@ -38,7 +41,7 @@ module OperaWatir
38
41
  driver.quitOpera
39
42
  driver.startOpera
40
43
  end
41
-
44
+
42
45
  ######################################################################
43
46
  # Quits the driver without exiting Opera
44
47
  #
@@ -235,12 +238,24 @@ module OperaWatir
235
238
  # puts quick_widget.to_s
236
239
  # end
237
240
  #
238
- # @param win_name [String] name or [int] id of the window to retrieve the list of widgets from,
241
+ # @param window [String] name or [int] id of the window to retrieve the list of widgets from,
239
242
  #
240
243
  # @return [Array] Array of widgets retrieved from the window
241
244
  #
242
- def widgets(win_name)
243
- driver.getQuickWidgetList(win_name).map do |java_widget|
245
+ def widgets(window)
246
+
247
+ # If window specifies window name, and the active window has this name
248
+ # use its id to get the widgets,
249
+ if window.is_a? String
250
+ active_win_id = driver.getActiveQuickWindowID()
251
+ active_win_name = driver.getQuickWindowName(active_win_id)
252
+
253
+ #If the active window is of same type, then grab that one, not first
254
+ if active_win_name == window #e.g. Both Document Window
255
+ window = active_win_id
256
+ end
257
+ end
258
+ driver.getQuickWidgetList(window).map do |java_widget|
244
259
  case java_widget.getType
245
260
  when QuickWidget::WIDGET_ENUM_MAP[:button]
246
261
  QuickButton.new(self,java_widget)
@@ -281,8 +296,11 @@ module OperaWatir
281
296
  end.to_a
282
297
  end
283
298
 
284
- #@private
285
- # Retrieve all tabs
299
+ ####################################################
300
+ # Retrieves an array of all tabs (Document Windows)
301
+ #
302
+ # @return [Array] Array of windows
303
+ #
286
304
  def open_pages
287
305
  quick_windows.select { |win| win.name == "Document Window" }
288
306
  end
@@ -398,6 +416,24 @@ module OperaWatir
398
416
  def cache_preferences_path
399
417
  driver.getCachePreferencesPath()
400
418
  end
419
+
420
+ ######################################################################
421
+ # Returns the language string corresponding to the string_id provided
422
+ #
423
+ # @param string_id the string_id to convert to the corresponding
424
+ # language string
425
+ # @param skip_ampersand if false, then leave string as is, else
426
+ # (default) remove any ampersand in string
427
+ #
428
+ #
429
+ # @example
430
+ # browser.string("D_NEW_PREFERENCES_GENERAL")
431
+ #
432
+ # @return [String] the language string corresponding to the string_id
433
+ #
434
+ def string(string_id, skip_ampersand = true)
435
+ string = driver.getString(string_id, skip_ampersand)
436
+ end
401
437
 
402
438
  ######################################################################
403
439
  # Returns true if the test is running on Mac
@@ -525,16 +561,55 @@ module OperaWatir
525
561
  driver.deleteOperaPrefs
526
562
  end
527
563
 
564
+ # Set preference pref in prefs section prefs_section to value
565
+ # specified.
566
+ #
567
+ # @param [String] prefs_section The prefs section the pref belongs to
568
+ # @param [String] pref The preference to set
569
+ # @param [String] value The value to set the preference to
570
+ def set_preference(prefs_section, pref, value)
571
+ driver.setPref(prefs_section, pref, value.to_s)
572
+ end
573
+
574
+ # Get value of preference pref in prefs section prefs_section.
575
+ #
576
+ # @param [String] prefs_section The prefs section the pref belongs to
577
+ # @param [String] pref The preference to get
578
+ #
579
+ # @return [String] The value of the preference
580
+ def get_preference(prefs_section, pref)
581
+ driver.getPref(prefs_section, pref)
582
+ end
583
+
584
+ # Get default value of preference pref in prefs section
585
+ # prefs_section.
586
+ #
587
+ # @param [String] prefs_section The prefs section the pref belongs to
588
+ # @param [String] pref The preference to get
589
+ #
590
+ # @return [String] The value of the preference
591
+ def get_default_preference(prefs_section, pref)
592
+ driver.getDefaultPref(prefs_section, pref)
593
+ end
594
+
595
+ # @private
596
+ def start_opera
597
+ driver.startOpera
598
+ end
599
+
528
600
  private
529
601
 
530
602
  def self.opera_driver_settings
531
603
  @opera_driver_settings ||= OperaDriverSettings.new.tap {|s|
532
604
  s.setRunOperaLauncherFromOperaDriver true
605
+ s.setAutostart false if self.settings[:manual]
533
606
  s.setOperaLauncherBinary self.settings[:launcher]
534
607
  s.setOperaBinaryLocation self.settings[:path]
535
- s.setOperaBinaryArguments self.settings[:args] + ' -watirtest'
608
+ s.setOperaBinaryArguments self.settings[:args].to_s + ' -autotestmode'
536
609
  s.setNoQuit self.settings[:no_quit]
537
610
  s.setNoRestart self.settings[:no_restart]
611
+ s.setGuessOperaPath false
612
+ s.setUseOperaIdle false if !self.settings[:opera_idle]
538
613
  }
539
614
  end
540
615
 
@@ -550,4 +625,3 @@ private
550
625
  end
551
626
 
552
627
  end
553
-
@@ -41,14 +41,12 @@ private
41
41
  end
42
42
 
43
43
  def key_down(key, *opts)
44
- puts "keydown"
45
44
  list = Java::JavaUtil::ArrayList.new
46
45
  opts.each { |mod| list << KEYMODIFIER_ENUM_MAP[mod] }
47
46
  driver.keyDown(key, list)
48
47
  end
49
48
 
50
49
  def key_up(key, *opts)
51
- puts "keyup"
52
50
  list = Java::JavaUtil::ArrayList.new
53
51
  opts.each { |mod| list << KEYMODIFIER_ENUM_MAP[mod] }
54
52
  driver.keyUp(key, list)
@@ -14,7 +14,12 @@ module OperaWatir
14
14
  # @return [Object] button object if found, otherwise nil
15
15
  #
16
16
  def quick_button(how, what)
17
- QuickButton.new(self, how, what, parent_widget, window_id)
17
+ if how == :pos
18
+ if what.is_a? Fixnum
19
+ what = [0, what]
20
+ end
21
+ end
22
+ QuickButton.new(self, how, what, parent_widget, window_id, :button)
18
23
  end
19
24
 
20
25
  ######################################################################
@@ -36,7 +41,7 @@ module OperaWatir
36
41
  what = [0, what]
37
42
  end
38
43
  end
39
- QuickTab.new(self, how, what, parent_widget, window_id)
44
+ QuickTab.new(self, how, what, parent_widget, window_id, :tabbutton)
40
45
  end
41
46
 
42
47
  ######################################################################
@@ -51,7 +56,7 @@ module OperaWatir
51
56
  # @return [Object] checkbox object if found, otherwise nil
52
57
  #
53
58
  def quick_checkbox(how, what)
54
- QuickCheckbox.new(self, how, what, parent_widget, window_id)
59
+ QuickCheckbox.new(self, how, what, parent_widget, window_id, :checkbox)
55
60
  end
56
61
 
57
62
  ######################################################################
@@ -66,7 +71,7 @@ module OperaWatir
66
71
  # @return [Object] dialog tab object if found, otherwise nil
67
72
  #
68
73
  def quick_dialogtab(how, what)
69
- QuickDialogTab.new(self, how, what, parent_widget, window_id)
74
+ QuickDialogTab.new(self, how, what, parent_widget, window_id, :dialogtab)
70
75
  end
71
76
 
72
77
  ######################################################################
@@ -81,10 +86,24 @@ module OperaWatir
81
86
  # @return [Object] drop down object if found, otherwise nil
82
87
  #
83
88
  def quick_dropdown(how, what)
84
- QuickDropdown.new(self, how, what, parent_widget, window_id)
89
+ QuickDropdown.new(self, how, what, parent_widget, window_id, :dropdown)
85
90
  end
86
91
 
87
-
92
+ ######################################################################
93
+ # Method for accessing a quickfind element
94
+ #
95
+ # @example
96
+ # browser.quick_find(:name, "Filetypes_quickfind")
97
+ #
98
+ # @param [String] how Method to find the element. :name, :string_id or :text
99
+ # @param [String] what Search text to find the element with.
100
+ #
101
+ # @return [Object] quickfind object if found, otherwise nil
102
+ #
103
+ def quick_find(how, what)
104
+ QuickFind.new(self, how, what, parent_widget, window_id, :quickfind)
105
+ end
106
+
88
107
  ######################################################################
89
108
  # Method for accessing an edit or multiedit element
90
109
  #
@@ -97,7 +116,7 @@ module OperaWatir
97
116
  # @return [Object] edit field object if found, otherwise nil
98
117
  #
99
118
  def quick_editfield(how, what)
100
- QuickEditField.new(self, how, what, parent_widget, window_id)
119
+ QuickEditField.new(self, how, what, parent_widget, window_id, :editfield)
101
120
  end
102
121
 
103
122
  ######################################################################
@@ -112,7 +131,7 @@ module OperaWatir
112
131
  # @return [Object] label object if found, otherwise nil
113
132
  #
114
133
  def quick_label(how, what)
115
- QuickLabel.new(self, how, what, parent_widget, window_id)
134
+ QuickLabel.new(self, how, what, parent_widget, window_id, :label)
116
135
  end
117
136
 
118
137
  ######################################################################
@@ -127,7 +146,7 @@ module OperaWatir
127
146
  # @return [Object] radio button object if found, otherwise nil
128
147
  #
129
148
  def quick_radiobutton(how, what)
130
- QuickRadioButton.new(self, how, what, parent_widget, window_id)
149
+ QuickRadioButton.new(self, how, what, parent_widget, window_id, :radiobutton)
131
150
  end
132
151
 
133
152
  ######################################################################
@@ -142,7 +161,7 @@ module OperaWatir
142
161
  # @return [Object] treeview object if found, otherwise nil
143
162
  #
144
163
  def quick_treeview(how, what)
145
- QuickTreeView.new(self, how, what, parent_widget, window_id)
164
+ QuickTreeView.new(self, how, what, parent_widget, window_id, :treeview)
146
165
  end
147
166
 
148
167
  ######################################################################
@@ -157,7 +176,7 @@ module OperaWatir
157
176
  # @return [Object] addressfield object if found, otherwise nil
158
177
  #
159
178
  def quick_addressfield(how, what)
160
- QuickAddressField.new(self, how, what, parent_widget, window_id)
179
+ QuickAddressField.new(self, how, what, parent_widget, window_id, :addressfield)
161
180
  end
162
181
 
163
182
  ######################################################################
@@ -172,7 +191,7 @@ module OperaWatir
172
191
  # @return [Object] searchfield object if found, otherwise nil
173
192
  #
174
193
  def quick_searchfield(how, what)
175
- QuickSearchField.new(self, how, what, parent_widget, window_id)
194
+ QuickSearchField.new(self, how, what, parent_widget, window_id, :search)
176
195
  end
177
196
 
178
197
  ######################################################################
@@ -187,7 +206,7 @@ module OperaWatir
187
206
  # @return [Object] toolbar object if found, otherwise nil
188
207
  #
189
208
  def quick_toolbar(how, what)
190
- QuickToolbar.new(self, how, what, parent_widget, window_id)
209
+ QuickToolbar.new(self, how, what, parent_widget, window_id, :toolbar)
191
210
  end
192
211
 
193
212
  ######################################################################
@@ -203,29 +222,63 @@ module OperaWatir
203
222
  # @return [Object] treeitem object if found, otherwise nil
204
223
  #
205
224
  def quick_treeitem(how, what)
206
- QuickTreeItem.new(self, how, what, parent_widget, window_id)
225
+ QuickTreeItem.new(self, how, what, parent_widget, window_id, :treeitem)
207
226
  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
- #
227
+
228
+ ######################################################################
229
+ # Method for accessing a grid item in a gridlayout
230
+ #
231
+ # @example (The label dialog for mail labels)
232
+ # browser.quick_gridlayout(:name, "RulesGrid").quick_griditem(:name, "GridItem0").quick_editfield(:name, "Match")
233
+ #
234
+ # @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
236
+ # of treeitem. Position is specified as [row, column]
237
+ #
238
+ # @return [Object] griditem object if found, otherwise nil
239
+ #
240
+ def quick_griditem(how, what)
241
+ QuickGridItem.new(self, how, what, parent_widget, window_id, :griditem)
242
+ end
243
+
244
+ ######################################################################
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.
247
+ #
248
+ # @example (The label dialog for mail labels)
249
+ # browser.quick_gridlayout(:name, "RulesGrid").quick_griditem(:name, "GridItem0").quick_editfield(:name, "Match")
250
+ #
251
+ # @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
253
+ # of treeitem. Position is specified as [row, column]
254
+ #
255
+ # @return [Object] gridlayout object if found, otherwise nil
256
+ #
257
+ def quick_gridlayout(how, what)
258
+ QuickGridLayout.new(self, how, what, parent_widget, window_id, :gridlayout)
259
+ end
260
+
261
+
262
+ ######################################################################
263
+ # Method for accessing a thumbnail (speeddial, thumbnail when hovering tab groups)
264
+ #
265
+ # @example
266
+ # browser.quick_thumbnail(:name, "Thumbnail 1")
267
+ # browser.quick_thumbnail(:name, "Speed Dial 2")
268
+ #
269
+ # @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
271
+ # of treeitem. Position is specified as [row, column]
272
+ #
273
+ # @return [Object] thumbnail object if found, otherwise nil
274
+ #
222
275
  def quick_thumbnail(how, what)
223
276
  if how == :pos
224
277
  if what.is_a? Fixnum
225
278
  what = [0, what]
226
279
  end
227
280
  end
228
- QuickThumbnail.new(self, how, what, parent_widget, window_id)
281
+ QuickThumbnail.new(self, how, what, parent_widget, window_id, :thumbnail)
229
282
  end
230
283
 
231
284
  ######################################################################