operawatir 0.4.3.pre1-jruby → 0.5-jruby

Sign up to get free protection for your applications and to get access to all the features.
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,4 +1,4 @@
1
- %w(quick_widget quick_button quick_checkbox quick_editfield
2
- quick_dropdown quick_dialogtab quick_label quick_radiobutton quick_treeview quick_addressfield
1
+ %w(quick_widget quick_button quick_checkbox quick_editfield
2
+ quick_dropdown quick_dialogtab quick_label quick_radiobutton quick_treeview quick_addressfield
3
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}"}
4
+ quick_find quick_griditem quick_gridlayout quick_menu quick_menuitem quick_dropdownitem).each {|widget| require "operawatir/quickwidgets/#{widget}"}
@@ -8,21 +8,26 @@ module OperaWatir
8
8
  @element.getType == WIDGET_ENUM_MAP[:addressfield]
9
9
  end
10
10
 
11
- # Enters the url into the address field, and waits for page loading
11
+ # Enters the url into the address field, and waits for page loading
12
12
  # to finish
13
13
  #
14
+ # @example (with RSpec)
15
+ # addressfield.load_page_with_url("opera:debug").should == "opera:debug"
16
+ #
14
17
  # @param [String] URL to load
15
18
  # @return [String] text in the address field after the page is loaded
16
19
  # or a blank string
17
20
  # @raise [Exceptions::UnknownObjectException] if the widget could not be found
18
21
  # using the specified method
22
+ #
19
23
  def load_page_with_url(url)
20
24
  # Must focus field before calling enter_text...
21
25
  focus_with_click
26
+
22
27
  # Enters text in a field and then hits enter
23
28
  enter_text_and_hit_enter(url)
24
29
  end
25
-
30
+
26
31
  #
27
32
  # Gets the visible text in the address field
28
33
  #
@@ -30,10 +35,11 @@ module OperaWatir
30
35
  #
31
36
  # @raise [Exceptions::UnknownObjectException] if the widget could not be found
32
37
  # using the specified method
38
+ #
33
39
  def visible_text
34
40
  element.getVisibleText()
35
41
  end
36
-
42
+
37
43
  #
38
44
  # Gets the highlighted text in the address field
39
45
  #
@@ -41,9 +47,10 @@ module OperaWatir
41
47
  #
42
48
  # @raise [Exceptions::UnknownObjectException] if the widget could not be found
43
49
  # using the specified method
50
+ #
44
51
  def highlighted_text
45
- element.getAdditionalText()
52
+ element.getAdditionalText()
46
53
  end
47
-
54
+
48
55
  end
49
56
  end
@@ -1,6 +1,7 @@
1
1
  module OperaWatir
2
2
  class QuickButton < QuickWidget
3
-
3
+ include ClickableItem
4
+
4
5
  # @private
5
6
  # Checks the type of the widget is correct
6
7
  def correct_type?
@@ -16,29 +17,13 @@ module OperaWatir
16
17
  element.isDefault
17
18
  end
18
19
 
19
- ######################################################################
20
- # Clicks the button, and waits for the window with window name
21
- # win_name to be shown
22
- #
23
- # @param [String] win_name name of the window that will be opened (Pass a blank string for any window)
24
- #
25
- # @return [int] Window ID of the window shown or 0 if no window is shown
26
- #
27
- # @raise [DesktopExceptions::WidgetNotVisibleException] if the button
28
- # is not visible
29
- #
30
- def open_window_with_click(win_name)
31
- wait_start
32
- click
33
- wait_for_window_shown(win_name)
34
- end
35
-
36
- alias_method :open_dialog_with_click, :open_window_with_click
37
-
38
20
  ######################################################################
39
21
  # Clicks the button, and waits for the dialog wizard to switch
40
22
  # to the next page
41
23
  #
24
+ # @example
25
+ # browser.quick_button(:name, "button_Next").change_page_with_click
26
+ #
42
27
  # @return [int] Window ID of the dialog wizard or 0 if no window is shown
43
28
  #
44
29
  # @raise [DesktopExceptions::WidgetNotVisibleException] if the button
@@ -49,9 +34,10 @@ module OperaWatir
49
34
  click
50
35
  wait_for_window_shown("")
51
36
  end
52
-
37
+
38
+
53
39
  ######################################################################
54
- # Clicks the button, and waits for the window with window name
40
+ # Clicks the button, and waits for the window with window name
55
41
  # win_name to closed
56
42
  #
57
43
  # @param [String] win_name name of the window that will be closed (Pass a blank string for any window)
@@ -66,25 +52,10 @@ module OperaWatir
66
52
  click
67
53
  wait_for_window_close(win_name)
68
54
  end
69
-
55
+
70
56
  alias_method :close_dialog_with_click, :close_window_with_click
71
-
72
- ######################################################################
73
- # Clicks the button, and waits for loading to finish
74
- #
75
- # @return [int] Window ID of the window shown or 0 if no window is shown
76
- #
77
- # @raise [DesktopExceptions::WidgetNotVisibleException] if the button
78
- # is not visible
79
- #
80
- def load_page_with_click
81
- wait_start
82
- click()
83
- # Just wait for the load
84
- wait_for_window_loaded("")
85
- end
86
-
87
-
57
+
58
+
88
59
  ######################################################################
89
60
  # Clicks a button or expand control and toggles it state
90
61
  #
@@ -97,10 +68,10 @@ module OperaWatir
97
68
  #
98
69
  def toggle_with_click
99
70
  click
100
-
101
- # Cheat since we don't have an event yet
71
+
72
+ # Cheat since we don't have an event yet
102
73
  sleep(0.1)
103
-
74
+
104
75
  # Note: click might have made this element dissapear ...
105
76
  begin
106
77
  element(true).getValue
@@ -108,22 +79,25 @@ module OperaWatir
108
79
  nil
109
80
  end
110
81
  end
111
-
82
+
112
83
  ######################################################################
113
- # Clicks button to close the toolbar
84
+ # Clicks button to close the toolbar
85
+ #
86
+ # @example
87
+ # browser.quick_toolbar(:name, "Go To Intranet Toolbar").quick_button(:name, "Done").close_toolbar_with_click
114
88
  #
115
89
  # @raise [DesktopExceptions::WidgetNotVisibleException] if the button
116
90
  # is not visible
117
91
  #
118
92
  def close_toolbar_with_click
119
93
  click
120
-
94
+
121
95
  # Cheat since we don't have an event yet
122
96
  sleep(0.1)
123
97
  end
124
-
98
+
125
99
  alias_method :close_panel_with_click, :close_toolbar_with_click
126
-
100
+
127
101
  ######################################################################
128
102
  # Clicks button to expand or collapse the toolbar
129
103
  #
@@ -135,9 +109,9 @@ module OperaWatir
135
109
  sleep(0.1)
136
110
  #No refresh element because it might not be there still (after click):)
137
111
  end
138
-
112
+
139
113
  alias_method :collapse_with_click, :expand_with_click
140
-
114
+
141
115
  ######################################################################
142
116
  # Gets the value of the button or expand control.
143
117
  #
@@ -148,16 +122,28 @@ module OperaWatir
148
122
  def value
149
123
  element.getValue
150
124
  end
151
-
125
+
152
126
  ######################################################################
153
127
  # Pauses to wait for security dialogs when buttons are not active
154
- # right away on opening
128
+ # right away on opening
129
+ #
130
+ # @example (RSpec)
131
+ # browser.quick_button(:name, "button_OK").wait_for_enabled.should == true
155
132
  #
156
133
  # @return [Boolean] Returns true if the button becomes active
157
134
  #
158
135
  def wait_for_enabled
159
136
  wait_for_widget_enabled
160
137
  end
161
-
138
+
139
+ ######################################################################
140
+ # Waits for widget to be visible
141
+ #
142
+ # @return [Boolean] Returns true if the button becomes active
143
+ #
144
+ def wait_for_visible
145
+ wait_for_widget_visible
146
+ end
147
+
162
148
  end
163
149
  end
@@ -1,6 +1,6 @@
1
1
  module OperaWatir
2
2
  class QuickCheckbox < QuickWidget
3
-
3
+
4
4
  # @private
5
5
  # Checks the type of the widget is correct
6
6
  def correct_type?
@@ -17,7 +17,7 @@ module OperaWatir
17
17
  def checked?
18
18
  element.isSelected
19
19
  end
20
-
20
+
21
21
  ######################################################################
22
22
  # Clicks a radio button or checkbox and toggles it state
23
23
  #
@@ -29,17 +29,17 @@ module OperaWatir
29
29
  #
30
30
  def toggle_with_click
31
31
  click
32
-
33
- # Cheat since we don't have an even yet
32
+
33
+ # Cheat since we don't have an even yet
34
34
  sleep(0.1)
35
35
 
36
36
  # is this guaranteed to be same as getValue?
37
37
  element(true).isSelected
38
38
  end
39
39
 
40
-
40
+
41
41
  ######################################################################
42
- # Clicks the checkbox, and waits for the window with window name
42
+ # Clicks the checkbox, and waits for the window with window name
43
43
  # win_name to be shown
44
44
  #
45
45
  # @param [String] win_name name of the window that will be opened (Pass a blank string for any window)
@@ -6,18 +6,18 @@ module OperaWatir
6
6
  def correct_type?
7
7
  @element.getType == WIDGET_ENUM_MAP[:dialogtab]
8
8
  end
9
-
9
+
10
10
  ######################################################################
11
- # Switches to the dialog tab by clicking on it
11
+ # Switches to the dialog tab by clicking on it
12
12
  #
13
- # @raise [DesktopExceptions::WidgetNotVisibleException] if the dialogtab
13
+ # @raise [DesktopExceptions::WidgetNotVisibleException] if the dialogtab
14
14
  # is not visible
15
15
  #
16
16
  def activate_tab_with_click
17
17
  click
18
-
18
+
19
19
  # No event yet so just cheat and sleep
20
20
  sleep(0.1);
21
21
  end
22
- end
22
+ end
23
23
  end
@@ -6,7 +6,7 @@ module OperaWatir
6
6
  def correct_type?
7
7
  @element.getType == WIDGET_ENUM_MAP[:dropdown]
8
8
  end
9
-
9
+
10
10
  ######################################################################
11
11
  # Checks if the item selected in the dropdown matches the text loaded
12
12
  # from Opera using the string_id
@@ -14,14 +14,38 @@ module OperaWatir
14
14
  # @param [String] string_id String ID to use to load the string from the current
15
15
  # language file (e.g. "D_NEW_PREFERENCES_GENERAL")
16
16
  #
17
- # @return [Boolean] true if the dropdown has the item with the
17
+ # @return [Boolean] true if the dropdown has the item with the
18
18
  # string_id selected, otherwise false
19
19
  #
20
20
  # @raise [Exceptions::UnknownObjectException] if the widget could not be found
21
21
  # using the specified method
22
+ #
22
23
  def selected?(string_id)
23
24
  element.isSelected(string_id)
24
25
  end
25
-
26
+
27
+ #########################################################################
28
+ #
29
+ # @example
30
+ # browser.quick_dropdown(:name, "Close_tab_dropdown").dropped_down?
31
+ #
32
+ # @return true if dropdown is dropped_down/open, else false
33
+ #
34
+ def dropped_down?
35
+ element.getValue() > 0
36
+ end
37
+
38
+
39
+ ############################################################################
40
+ # Click dropdown to open it
41
+ #
42
+ # @example
43
+ # browser.quick_dropdown(:name, "Close_tab_dropdown").open_with_click
44
+ #
45
+ def open_with_click
46
+ click
47
+ sleep(0.1)
48
+ end
49
+
26
50
  end
27
- end
51
+ end
@@ -0,0 +1,46 @@
1
+ module OperaWatir
2
+ class QuickDropdownItem < QuickEditField #QuickWidget # QuickEditField?
3
+
4
+ # @private
5
+ # Checks the type of the widget is correct
6
+ def correct_type?
7
+ @element.getType == WIDGET_ENUM_MAP[:dropdownitem]
8
+ end
9
+
10
+ ######################################################################
11
+ # Checks if the item is selected
12
+ #
13
+ # @return [Boolean] true if the dropdown has the item with the
14
+ # string_id selected, otherwise false
15
+ #
16
+ # @raise [Exceptions::UnknownObjectException] if the widget could not be found
17
+ # using the specified method
18
+ def selected?
19
+ element(true).isSelected()
20
+ end
21
+
22
+ ##########################################################################
23
+ # Select item by click
24
+ #
25
+ # @example
26
+ # browser.quick_dropdownitem(:text, "Activate the next tab").select_with_click
27
+ #
28
+ # @return true if item is now selected, otherwise false
29
+ #
30
+ def select_with_click
31
+ if mac_internal?
32
+ press_menu
33
+ else
34
+ click
35
+ end
36
+ selected?
37
+ end
38
+
39
+ private
40
+
41
+ # Selects an item from a drop down pop menu where you can't click them on Mac
42
+ def press_menu
43
+ driver.pressQuickMenuItem(text, true);
44
+ end
45
+ end
46
+ end
@@ -10,13 +10,16 @@ module OperaWatir
10
10
  ######################################################################
11
11
  # Sets focus to the edit field by clicking on it
12
12
  #
13
- # @raise [DesktopExceptions::WidgetNotVisibleException] if the editfield
13
+ # @example
14
+ # browser.quick_editfield(:name, "Startpage_edit").focus_with_clic
15
+ #
16
+ # @raise [DesktopExceptions::WidgetNotVisibleException] if the editfield
14
17
  # is not visible
15
18
  #
16
19
  def focus_with_click
17
20
  super
18
21
  end
19
-
22
+
20
23
  ######################################################################
21
24
  # Types a text string into the edit field
22
25
  #
@@ -25,20 +28,20 @@ module OperaWatir
25
28
  #
26
29
  # @param [String] text text string to type in
27
30
  # @param wait - seconds to wait after typing
28
- #
31
+ #
29
32
  # @return [String] contents of the edit field after typing has completed
30
33
  #
31
34
  def type_text(text, wait = 0)
32
35
  text.each_char { | t | key_press_direct t }
33
-
36
+
34
37
  # No event yet so just cheat and sleep
35
38
  sleep(0.2)
36
39
 
37
40
  # Return what is in the field to check
38
41
  text = element(true).getText
39
-
42
+
40
43
  sleep(wait) if wait != 0
41
-
44
+
42
45
  text
43
46
  end
44
47
 
@@ -47,10 +50,10 @@ module OperaWatir
47
50
  #
48
51
  def clear
49
52
  focus_with_click
50
-
53
+
51
54
  key_press_direct("a", :ctrl)
52
55
  key_press_direct("backspace")
53
-
56
+
54
57
  # Cheat until we have an event
55
58
  sleep(0.1)
56
59
  end
@@ -74,7 +77,7 @@ module OperaWatir
74
77
  #
75
78
  def key_press(key, *modifiers)
76
79
  key_press_direct(key, *modifiers)
77
-
80
+
78
81
  # Cheat until we have an event
79
82
  sleep(0.1)
80
83
 
@@ -82,7 +85,7 @@ module OperaWatir
82
85
  element(true).getText
83
86
  end
84
87
 
85
- private
88
+ private
86
89
  # @private
87
90
  # Presses the key, and waits for loading to finish
88
91
  def load_page_with_key_press(key, *modifiers)
@@ -95,12 +98,12 @@ module OperaWatir
95
98
  # Enter some text and hit enter to do the action for the field
96
99
  def enter_text_and_hit_enter(text)
97
100
  loaded_url = ""
98
-
99
- # OBS: only caller should set focus, if not this will happily type
101
+
102
+ # OBS: only caller should set focus, if not this will happily type
100
103
  # away in the incorrect field, if for example called from subclass address_field
101
104
  # Set focus
102
105
  # focus_with_click
103
-
106
+
104
107
  # Clear the field
105
108
  clear
106
109
  # Type in the text