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,3 +1,4 @@
1
1
  %w(quick_widget quick_button quick_checkbox quick_editfield
2
2
  quick_dropdown quick_dialogtab quick_label quick_radiobutton quick_treeview quick_addressfield
3
- quick_searchfield quick_toolbar quick_window quick_tab quick_treeitem quick_thumbnail).each {|widget| require "operawatir/quickwidgets/#{widget}"}
3
+ quick_searchfield quick_toolbar quick_window quick_tab quick_treeitem quick_thumbnail
4
+ quick_find quick_griditem quick_gridlayout).each {|widget| require "operawatir/quickwidgets/#{widget}"}
@@ -14,7 +14,11 @@ module OperaWatir
14
14
  # @param [String] URL to load
15
15
  # @return [String] text in the address field after the page is loaded
16
16
  # or a blank string
17
+ # @raise [Exceptions::UnknownObjectException] if the widget could not be found
18
+ # using the specified method
17
19
  def load_page_with_url(url)
20
+ # Must focus field before calling enter_text...
21
+ focus_with_click
18
22
  # Enters text in a field and then hits enter
19
23
  enter_text_and_hit_enter(url)
20
24
  end
@@ -22,6 +26,10 @@ module OperaWatir
22
26
  #
23
27
  # Gets the visible text in the address field
24
28
  #
29
+ # @return [String] visible text in address field
30
+ #
31
+ # @raise [Exceptions::UnknownObjectException] if the widget could not be found
32
+ # using the specified method
25
33
  def visible_text
26
34
  element.getVisibleText()
27
35
  end
@@ -29,6 +37,10 @@ module OperaWatir
29
37
  #
30
38
  # Gets the highlighted text in the address field
31
39
  #
40
+ # @return [String] higlighted text in address field, if any, else empty
41
+ #
42
+ # @raise [Exceptions::UnknownObjectException] if the widget could not be found
43
+ # using the specified method
32
44
  def highlighted_text
33
45
  element.getAdditionalText()
34
46
  end
@@ -89,7 +89,8 @@ module OperaWatir
89
89
  # Clicks a button or expand control and toggles it state
90
90
  #
91
91
  # @return [int] the new state of the button or expand control,
92
- # 0 for not pressed, or 1 for pressed
92
+ # 0 for not pressed, or 1 for pressed,
93
+ # nil if the element does no longer exist
93
94
  #
94
95
  # @raise [DesktopExceptions::WidgetNotVisibleException] if the button
95
96
  # is not visible
@@ -100,7 +101,12 @@ module OperaWatir
100
101
  # Cheat since we don't have an event yet
101
102
  sleep(0.1)
102
103
 
103
- element(true).getValue
104
+ # Note: click might have made this element dissapear ...
105
+ begin
106
+ element(true).getValue
107
+ rescue Exceptions::UnknownObjectException
108
+ nil
109
+ end
104
110
  end
105
111
 
106
112
  ######################################################################
@@ -21,7 +21,7 @@ module OperaWatir
21
21
  ######################################################################
22
22
  # Clicks a radio button or checkbox and toggles it state
23
23
  #
24
- # @return [int] the new state of the radio button or checkbox,
24
+ # @return [Boolean] the new state of the radio button or checkbox,
25
25
  # false for not checked, or true for checked
26
26
  #
27
27
  # @raise [DesktopExceptions::WidgetNotVisibleException] if the checkbox
@@ -33,6 +33,7 @@ module OperaWatir
33
33
  # Cheat since we don't have an even yet
34
34
  sleep(0.1)
35
35
 
36
+ # is this guaranteed to be same as getValue?
36
37
  element(true).isSelected
37
38
  end
38
39
 
@@ -49,10 +50,9 @@ module OperaWatir
49
50
  # is not visible
50
51
  #
51
52
  def open_dialog_with_click(win_name)
52
- super
53
- #wait_start
54
- #click
55
- #wait_for_window_shown(win_name)
53
+ wait_start
54
+ click
55
+ wait_for_window_shown(win_name)
56
56
  end
57
57
 
58
58
  end
@@ -20,7 +20,7 @@ module OperaWatir
20
20
  ######################################################################
21
21
  # Types a text string into the edit field
22
22
  #
23
- # @note Only chanracters that appear on the keyboard that is currently
23
+ # @note Only characters that appear on the keyboard that is currently
24
24
  # selected can be typed, and the edit field must have focus.
25
25
  #
26
26
  # @param [String] text text string to type in
@@ -45,9 +45,9 @@ module OperaWatir
45
45
  ######################################################################
46
46
  # Clears the contents of the edit field
47
47
  #
48
- # @note The edit field must have focus for this method to work
49
- #
50
48
  def clear
49
+ focus_with_click
50
+
51
51
  key_press_direct("a", :ctrl)
52
52
  key_press_direct("backspace")
53
53
 
@@ -96,10 +96,13 @@ module OperaWatir
96
96
  def enter_text_and_hit_enter(text)
97
97
  loaded_url = ""
98
98
 
99
+ # OBS: only caller should set focus, if not this will happily type
100
+ # away in the incorrect field, if for example called from subclass address_field
99
101
  # Set focus
100
- focus_with_click
102
+ # focus_with_click
103
+
101
104
  # Clear the field
102
- clear()
105
+ clear
103
106
  # Type in the text
104
107
  typed_text = type_text(text) #Opens dropdown window
105
108
  # Check that some text was typed, note the text might be changed in the
@@ -0,0 +1,11 @@
1
+ module OperaWatir
2
+ class QuickFind < QuickDropdown
3
+
4
+ # @private
5
+ # Checks the type of the widget is correct
6
+ def correct_type?
7
+ @element.getType == WIDGET_ENUM_MAP[:quickfind]
8
+ end
9
+
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module OperaWatir
2
+ class QuickGridItem < QuickWidget
3
+
4
+ # @private
5
+ # Checks the type of the widget is correct
6
+ def correct_type?
7
+ @element.getType == WIDGET_ENUM_MAP[:griditem]
8
+ end
9
+
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module OperaWatir
2
+ class QuickGridLayout < QuickWidget
3
+
4
+ # @private
5
+ # Checks the type of the widget is correct
6
+ def correct_type?
7
+ @element.getType == WIDGET_ENUM_MAP[:gridlayout]
8
+ end
9
+
10
+ end
11
+ end
@@ -17,8 +17,14 @@ module OperaWatir
17
17
  # or a blank string
18
18
  #
19
19
  def search_with_text(search_text)
20
+ # Must focus field before calling enter_text...
21
+ focus_with_click
22
+
20
23
  # Enters text in a field and then hits enter
21
- enter_text_and_hit_enter(search_text)
24
+ t = enter_text_and_hit_enter(search_text)
25
+
26
+ # return text in addressfield (in same window as search field)
27
+ driver.findWidgetByName(WIDGET_ENUM_MAP[:addressfield], @window_id, "tba_address_field", "Document Toolbar").getText
22
28
  end
23
29
 
24
30
  end
@@ -12,7 +12,6 @@ module OperaWatir
12
12
  #
13
13
  # @param [QuickTab] tab button to drop this tab on
14
14
  #
15
- #
16
15
  # @raise [DesktopExceptions::UnknownObjectException] if the target is not a tab
17
16
  #
18
17
  def move_with_drag(tab_target)
@@ -10,8 +10,10 @@ module OperaWatir
10
10
  ######################################################################
11
11
  # Set focus to the tree item by clicking on it
12
12
  #
13
- # @raise [DesktopExceptions::WidgetNotVisibleException] if the treeview
13
+ # @raise [DesktopExceptions::WidgetNotVisibleException] if the treeview
14
14
  # the treeitem is in is not visible
15
+ # @raise [DesktopExceptions::WidgetDisabledException] if the treeitem
16
+ # is disabled
15
17
  #
16
18
  def focus_with_click
17
19
  # First scroll the item into view
@@ -29,6 +31,8 @@ module OperaWatir
29
31
  # For now there is no difference to focusing
30
32
  focus_with_click
31
33
  end
34
+
35
+ alias_method :collapse_with_click, :expand_with_click
32
36
 
33
37
  ######################################################################
34
38
  # Expands a tree item when it is double clicked
@@ -111,6 +115,23 @@ module OperaWatir
111
115
  end
112
116
 
113
117
  alias_method :open_dialog_with_double_click, :open_window_with_double_click
118
+
119
+ ######################################################################
120
+ # Double clicks the tree item, and waits for the window with
121
+ # window name win_name to be loaded with the url of the treeitem
122
+ #
123
+ # @param [String] win_name name of the window that will be loaded (Pass a blank string for any window)
124
+ #
125
+ # @return [int] Window ID of the window shown or 0 if no window is shown
126
+ #
127
+ # @raise [DesktopExceptions::WidgetNotVisibleException] if the treeitem
128
+ # is not visible
129
+ #
130
+ def load_window_with_double_click(win_name)
131
+ wait_start
132
+ click(:left, 2)
133
+ wait_for_window_loaded(win_name)
134
+ end
114
135
 
115
136
 
116
137
  private
@@ -2,17 +2,20 @@ module OperaWatir
2
2
  class QuickWidget
3
3
  include DesktopCommon
4
4
  include DesktopContainer
5
+ include Deprecated
5
6
 
6
7
  # @private
7
8
  # window_id is set if constructor is called on a (parent) window
8
9
  # location is set is this is called on a (parent) widget
9
- def initialize(container, method, selector=nil, location=nil, window_id=-1)
10
+ def initialize(container, method, selector=nil, location=nil, window_id=-1, type=nil)
10
11
  @container = container
11
12
 
12
13
  if method.is_a? Java::ComOperaCoreSystems::QuickWidget
13
14
  @elm = method
15
+ @type = WIDGET_ENUM_MAP.invert[method.getType]
14
16
  else
15
17
  @method = method
18
+ @type = type
16
19
  @selector = selector
17
20
  @location = location
18
21
  @window_id = window_id
@@ -70,8 +73,7 @@ module OperaWatir
70
73
  # Gets the text of the widget
71
74
  #
72
75
  # @note This method should not be used to check the text in a widget if
73
- # the text is in the Opera language file. Use verify_text or
74
- # verify_includes_text instead
76
+ # the text is in the Opera language file. Use verify_text instead
75
77
  #
76
78
  # @return [String] text of the widget
77
79
  #
@@ -121,6 +123,7 @@ module OperaWatir
121
123
  ######################################################################
122
124
  # Checks that the text in the widget matches the text as loaded
123
125
  # from the current language file in Opera using the string_id
126
+ # (Strips &'s from the string before comparing)
124
127
  #
125
128
  # @param [String] string_id String ID to use to load the string from the current
126
129
  # language file (e.g. "D_NEW_PREFERENCES_GENERAL")
@@ -131,10 +134,17 @@ module OperaWatir
131
134
  # using the specified method
132
135
  #
133
136
  def verify_text(string_id)
134
- element.verifyText(string_id);
137
+ text = driver.getString(string_id, true) #true => stripAmpersands from string
138
+ if text.include? "%"
139
+ text.gsub!(/%[csduoxefg0-9]/, ".*")
140
+ res = /#{text}/ =~ element.getText()
141
+ res == nil ? false: true
142
+ else
143
+ element.verifyText(string_id)
144
+ end
135
145
  end
136
146
 
137
- alias_method :is_text?, :verify_text
147
+ alias_method :has_ui_string?, :verify_text
138
148
 
139
149
  ######################################################################
140
150
  # Checks that the text in the widget includes the text as loaded
@@ -153,6 +163,8 @@ module OperaWatir
153
163
  end
154
164
 
155
165
  alias_method :includes_text?, :verify_includes_text
166
+ deprecated :verify_includes_text
167
+ deprecated :includes_text?
156
168
 
157
169
  ######################################################################
158
170
  # Prints out all of the row/col information in single lines. Used to
@@ -187,8 +199,35 @@ module OperaWatir
187
199
  def position
188
200
  return [row, col] if type == :treeitem
189
201
  return col if type == :tabbutton
202
+ return col if type == :button
190
203
  false
191
204
  end
205
+
206
+ ########################################################################
207
+ #
208
+ # @return width of widget
209
+ #
210
+ def width
211
+ element.getRect().width
212
+ end
213
+
214
+ ########################################################################
215
+ #
216
+ # @return height of widget
217
+ #
218
+ def height
219
+ element.getRect().height
220
+ end
221
+
222
+ #@private
223
+ def x
224
+ element.getRect().x
225
+ end
226
+
227
+ #@private
228
+ def y
229
+ element.getRect().y
230
+ end
192
231
 
193
232
  ######################################################################
194
233
  # Prints out all of the internal information about the widget. Used
@@ -244,7 +283,7 @@ module OperaWatir
244
283
  def value
245
284
  return element.getValue
246
285
  end
247
-
286
+
248
287
  protected
249
288
  #@private
250
289
  # Return the element
@@ -256,8 +295,8 @@ protected
256
295
  raise(Exceptions::UnknownObjectException, "Element #{@selector} not found using #{@method}") unless @elm
257
296
  @elm
258
297
  end
259
-
260
-
298
+
299
+
261
300
  private
262
301
 
263
302
  def drag_and_drop_on(other, drop_pos)
@@ -303,16 +342,16 @@ private
303
342
 
304
343
  # Click widget
305
344
  def click(button = :left, times = 1, *opts)
306
- raise Exceptions::WidgetDisabledException, "Element #{@selector} is disabled" unless enabled?
307
-
345
+ raise DesktopExceptions::WidgetDisabledException, "Element #{@selector} is disabled" unless enabled?
346
+
308
347
  #Some buttons etc. aren't visible until hovering them
309
348
  if (visible? == false and type != :dialogtab)
310
349
  element.hover
311
350
  element(true)
312
351
  end
313
-
352
+
314
353
  # Dialog tabs are always visible even if the page they are connected to isn't
315
- if visible? == true or type == :dialogtab
354
+ if visible? == true or type == :dialogtab
316
355
  button = DesktopEnums::MOUSEBUTTON_ENUM_MAP[button]
317
356
  list = Java::JavaUtil::ArrayList.new
318
357
  opts.each { |mod| list << DesktopEnums::KEYMODIFIER_ENUM_MAP[mod] }
@@ -321,12 +360,12 @@ private
321
360
  raise(DesktopExceptions::WidgetNotVisibleException, "Widget #{name.length > 0 ? name : text} not visible")
322
361
  end
323
362
  end
324
-
363
+
325
364
  # Right click a widget
326
365
  def right_click
327
366
  click(:right, 1)
328
367
  end
329
-
368
+
330
369
  # double click widget
331
370
  def double_click
332
371
  click(:left, 2)
@@ -361,31 +400,31 @@ private
361
400
  if @selector == nil && @elm != nil
362
401
  set_selector
363
402
  end
364
- #puts "<find> Find Widget by " + @method.to_s + " " + @window_id.to_s + ", " + @selector.to_s + ", " + @location.to_s
403
+ #puts "\n<find> Find Widget by " + @method.to_s + " " + @window_id.to_s + ", " + @selector.to_s + ", " + @location.to_s + ", " + @type.to_s
365
404
  case @method
366
405
  when :name
367
406
  if @location != nil
368
- @element = driver.findWidgetByName(@window_id, @selector, @location)
407
+ @element = driver.findWidgetByName(WIDGET_ENUM_MAP[@type], @window_id, @selector, @location)
369
408
  else
370
- @element = driver.findWidgetByName(@window_id, @selector)
409
+ @element = driver.findWidgetByName(WIDGET_ENUM_MAP[@type], @window_id, @selector)
371
410
  end
372
411
  when :string_id
373
412
  if @location != nil
374
- @element = driver.findWidgetByStringId(@window_id, @selector, @location)
413
+ @element = driver.findWidgetByStringId(WIDGET_ENUM_MAP[@type], @window_id, @selector, @location)
375
414
  else
376
- @element = driver.findWidgetByStringId(@window_id, @selector)
415
+ @element = driver.findWidgetByStringId(WIDGET_ENUM_MAP[@type], @window_id, @selector)
377
416
  end
378
417
  when :text
379
418
  if @location != nil
380
- @element = driver.findWidgetByText(@window_id, @selector, @location)
419
+ @element = driver.findWidgetByText(WIDGET_ENUM_MAP[@type], @window_id, @selector, @location)
381
420
  else
382
- @element = driver.findWidgetByText(@window_id, @selector)
421
+ @element = driver.findWidgetByText(WIDGET_ENUM_MAP[@type], @window_id, @selector)
383
422
  end
384
423
  when :pos
385
424
  if @location != nil
386
- @element = driver.findWidgetByPosition(@window_id, @selector[0], @selector[1], @location)
425
+ @element = driver.findWidgetByPosition(WIDGET_ENUM_MAP[@type], @window_id, @selector[0], @selector[1], @location)
387
426
  else
388
- @element = driver.findWidgetByPosition(@window_id, @selector[0], @selector[1])
427
+ @element = driver.findWidgetByPosition(WIDGET_ENUM_MAP[@type], @window_id, @selector[0], @selector[1])
389
428
  end
390
429
  end
391
430
  if @window_id < 0 && @element != nil
@@ -32,6 +32,8 @@ module OperaWatir
32
32
  #
33
33
  # @return [Symbol] type of the window (e.g. :dropdown, :button)
34
34
  #
35
+ # @raise [Exceptions::UnknownObjectException] if the widget could not be found
36
+ # using the specified method
35
37
  def type
36
38
  return WINDOW_ENUM_MAP.invert[@elm.getType] unless @elm == nil
37
39
  return WINDOW_ENUM_MAP.invert[element.getType]
@@ -104,7 +106,33 @@ module OperaWatir
104
106
  def print_window_info
105
107
  puts window_info_string
106
108
  end
109
+
110
+ ########################################################################
111
+ #
112
+ # @return width of widget
113
+ #
114
+ def width
115
+ element.getRect().width
116
+ end
107
117
 
118
+ ########################################################################
119
+ #
120
+ # @return height of widget
121
+ #
122
+ def height
123
+ element.getRect().height
124
+ end
125
+
126
+ #@private
127
+ def x
128
+ element.getRect().x
129
+ end
130
+
131
+ #@private
132
+ def y
133
+ element.getRect().y
134
+ end
135
+
108
136
  ######################################################################
109
137
  # Returns a string of the internal information about the window. Used
110
138
  # to discover the names of widgets and windows to use in the tests.
@@ -149,8 +177,10 @@ private
149
177
  case @method
150
178
  when :name
151
179
  # Use active window when specifying by name "Document Window"
152
- # and not the first if there are more than one
153
- if (@selector == "Document Window")
180
+ # and not the first if there are more than one
181
+ active_window_id = driver.getActiveQuickWindowID()
182
+ name = driver.getQuickWindowName(active_window_id);
183
+ if (@selector == "Document Window" && name == "Document Window")
154
184
  @element = driver.findWindowById(driver.getActiveQuickWindowID())
155
185
  else
156
186
  @element = driver.findWindowByName(@selector)