operawatir 0.3.2-jruby → 0.3.7.pre1-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.
- data/.gitmodules +3 -0
- data/.yardopts +0 -3
- data/Gemfile +5 -6
- data/Rakefile +7 -2
- data/VERSION +1 -1
- data/bin/desktopwatir +86 -93
- data/bin/operawatir +3 -18
- data/lib/operadriver/commons-io-2.0.1.jar +0 -0
- data/lib/operadriver/selenium-common.jar +0 -0
- data/lib/operadriver/webdriver-opera.jar +0 -0
- data/lib/operawatir/browser.rb +93 -77
- data/lib/operawatir/compat/browser.rb +5 -0
- data/lib/operawatir/compat/element.rb +10 -17
- data/lib/operawatir/compat.rb +0 -1
- data/lib/operawatir/desktop-waiter.rb +1 -143
- data/lib/operawatir/desktop_browser.rb +80 -33
- data/lib/operawatir/desktop_enums.rb +3 -3
- data/lib/operawatir/desktop_helper.rb +84 -0
- data/lib/operawatir/element.rb +23 -4
- data/lib/operawatir/exceptions.rb +3 -0
- data/lib/operawatir/helper.rb +4 -1
- data/lib/operawatir/platform.rb +0 -38
- data/lib/operawatir/preferences.rb +164 -0
- data/lib/operawatir/quickwidgets/quick_addressfield.rb +14 -0
- data/lib/operawatir/quickwidgets/quick_button.rb +7 -1
- data/lib/operawatir/quickwidgets/quick_checkbox.rb +5 -4
- data/lib/operawatir/quickwidgets/quick_dialogtab.rb +1 -1
- data/lib/operawatir/quickwidgets/quick_editfield.rb +9 -4
- data/lib/operawatir/quickwidgets/quick_thumbnail.rb +1 -1
- data/lib/operawatir/quickwidgets/quick_treeitem.rb +2 -2
- data/lib/operawatir/quickwidgets/quick_treeview.rb +2 -1
- data/lib/operawatir/quickwidgets/quick_widget.rb +51 -21
- data/lib/operawatir/quickwidgets/quick_window.rb +34 -19
- data/lib/operawatir/spatnav.rb +38 -0
- data/lib/operawatir/window.rb +76 -12
- data/lib/operawatir.rb +20 -4
- data/operawatir.gemspec +48 -28
- data/spec/new_watirspec/browser_spec.rb +5 -84
- data/spec/new_watirspec/clipboard_spec.rb +41 -56
- data/spec/new_watirspec/collection_spec.rb +2 -2
- data/spec/new_watirspec/element_spec.rb +8 -8
- data/spec/new_watirspec/keys_spec.rb +8 -10
- data/spec/new_watirspec/preferences_spec.rb +144 -0
- data/spec/new_watirspec/screenshot_spec.rb +34 -0
- data/spec/new_watirspec/spatnav_spec.rb +62 -0
- data/utils/formatters/operahelper_formatter.rb +50 -0
- data/utils/formatters/spartan_formatter.rb +29 -0
- metadata +126 -61
- data/lib/operawatir/compat/deprecation.rb +0 -46
- data/utils/launchers/launcher-linux-i686 +0 -0
- data/utils/launchers/launcher-linux-x86_64 +0 -0
- data/utils/launchers/launcher-mac +0 -0
- data/utils/launchers/launcher-win32-i86pc.exe +0 -0
@@ -0,0 +1,164 @@
|
|
1
|
+
require 'inifile'
|
2
|
+
require 'tmpdir'
|
3
|
+
require 'pp'
|
4
|
+
require 'active_support/inflector'
|
5
|
+
|
6
|
+
class String
|
7
|
+
def keyize
|
8
|
+
self.humanize.titleize
|
9
|
+
end
|
10
|
+
|
11
|
+
def methodize
|
12
|
+
self.titleize.gsub(/\s+/, '').underscore
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class OperaWatir::Preferences
|
17
|
+
extend Forwardable
|
18
|
+
include Enumerable
|
19
|
+
|
20
|
+
attr_accessor :browser
|
21
|
+
|
22
|
+
# FIXME This should be retrievable from OperaDriver
|
23
|
+
SECTIONS = ['Author Display Mode', 'Auto Update', 'BitTorrent',
|
24
|
+
'CSS Generic Font Family', 'Cache', 'Clear Private Data Dialog',
|
25
|
+
'Colors', 'Developer Tools', 'Disk Cache', 'Extensions',
|
26
|
+
'File Selector', 'File Types Section Info', 'Fonts', 'Geolocation',
|
27
|
+
'Handheld', 'HotListWindow', 'ISP', 'Install', 'Interface Colors',
|
28
|
+
'Java', 'Link', 'Mail', 'MailBox', 'Multimedia', 'Network', 'News',
|
29
|
+
'OEM', 'Opera Account', 'Opera Sync', 'Performance', 'Persistent Storage',
|
30
|
+
'Personal Info', 'Printer', 'Proxy', 'SVG', 'Saved Settings',
|
31
|
+
'Security Prefs', 'Sounds', 'Special', 'Transfer Window',
|
32
|
+
'User Agent', 'User Display Mode', 'User Prefs', 'Visited Link',
|
33
|
+
'Visited Link', 'Web Server', 'Widgets', 'Workspace']
|
34
|
+
|
35
|
+
def initialize(browser)
|
36
|
+
self.browser = browser
|
37
|
+
end
|
38
|
+
|
39
|
+
# Section locator
|
40
|
+
def method_missing(section)
|
41
|
+
# @_prefs[section.to_s] ||= Entry.new self, section
|
42
|
+
Entry.new self, section
|
43
|
+
end
|
44
|
+
|
45
|
+
def cleanup; end
|
46
|
+
def cleanup!; end
|
47
|
+
|
48
|
+
def_delegators :sections, :each,
|
49
|
+
:length,
|
50
|
+
:size,
|
51
|
+
:first,
|
52
|
+
:last,
|
53
|
+
:empty?
|
54
|
+
|
55
|
+
alias_method :each_section, :each
|
56
|
+
|
57
|
+
def to_s
|
58
|
+
pp _prefs
|
59
|
+
end
|
60
|
+
|
61
|
+
def to_h
|
62
|
+
_prefs.dup
|
63
|
+
end
|
64
|
+
|
65
|
+
private
|
66
|
+
def sections
|
67
|
+
# @_prefs ||= all_prefs
|
68
|
+
all_prefs
|
69
|
+
end
|
70
|
+
|
71
|
+
def all_prefs
|
72
|
+
list = []
|
73
|
+
SECTIONS.each { |s| list << Entry.new(self, s.methodize) }
|
74
|
+
list
|
75
|
+
end
|
76
|
+
|
77
|
+
def load_from_file(file)
|
78
|
+
inifile = Loader.new file
|
79
|
+
loaded_prefs = IniFile.new inifile.output.path
|
80
|
+
|
81
|
+
loaded_prefs.each_section do |s|
|
82
|
+
s.each do |k,v|
|
83
|
+
driver.setPref s,k,v
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def driver
|
89
|
+
browser.driver
|
90
|
+
end
|
91
|
+
|
92
|
+
|
93
|
+
class Entry
|
94
|
+
extend Forwardable
|
95
|
+
include Enumerable
|
96
|
+
|
97
|
+
attr_accessor :parent, :method, :key, :value
|
98
|
+
|
99
|
+
def initialize(parent, method)
|
100
|
+
self.parent, self.method, self.key = parent, method, method.to_s.keyize
|
101
|
+
end
|
102
|
+
|
103
|
+
def method_missing(key)
|
104
|
+
Entry.new self, key
|
105
|
+
end
|
106
|
+
|
107
|
+
def value
|
108
|
+
return nil if is_section?
|
109
|
+
@value ||= driver.getPref parent.key, @key
|
110
|
+
end
|
111
|
+
|
112
|
+
def value=(value)
|
113
|
+
raise OperaWatir::Exceptions::PreferencesException, 'Sections cannot have values'
|
114
|
+
driver.setPref parent.key, @key, value
|
115
|
+
end
|
116
|
+
|
117
|
+
def default
|
118
|
+
return nil if is_section?
|
119
|
+
@default ||= driver.getDefaultPref parent.key, @key
|
120
|
+
end
|
121
|
+
|
122
|
+
def default!
|
123
|
+
raise OperaWatir::Exceptions::PreferencesException, 'Sections do not have defaults'
|
124
|
+
value=(default)
|
125
|
+
end
|
126
|
+
|
127
|
+
def each_key
|
128
|
+
return unless block_given?
|
129
|
+
raw_keys.each { |k| yield k }
|
130
|
+
end
|
131
|
+
|
132
|
+
alias_method :each, :each_key
|
133
|
+
|
134
|
+
def is_section?
|
135
|
+
@parent.kind_of? OperaWatir::Preferences
|
136
|
+
end
|
137
|
+
|
138
|
+
private
|
139
|
+
def driver
|
140
|
+
@parent.browser.driver || @parent.parent.browser.driver
|
141
|
+
end
|
142
|
+
|
143
|
+
def raw_keys
|
144
|
+
@_keys ||= all_keys
|
145
|
+
end
|
146
|
+
|
147
|
+
def all_keys
|
148
|
+
keys = []
|
149
|
+
|
150
|
+
driver.listPrefs(true, @key).to_a.each do |data|
|
151
|
+
data = data.to_s
|
152
|
+
|
153
|
+
data =~ /^key: \"([a-zA-Z0-9\(\)\\\.\-\s]*)\"/
|
154
|
+
key = $1.gsub(/\\t/, '')
|
155
|
+
|
156
|
+
keys << Entry.new(self, key.methodize)
|
157
|
+
end
|
158
|
+
|
159
|
+
keys
|
160
|
+
end
|
161
|
+
|
162
|
+
end
|
163
|
+
|
164
|
+
end
|
@@ -19,5 +19,19 @@ module OperaWatir
|
|
19
19
|
enter_text_and_hit_enter(url)
|
20
20
|
end
|
21
21
|
|
22
|
+
#
|
23
|
+
# Gets the visible text in the address field
|
24
|
+
#
|
25
|
+
def visible_text
|
26
|
+
element.getVisibleText()
|
27
|
+
end
|
28
|
+
|
29
|
+
#
|
30
|
+
# Gets the highlighted text in the address field
|
31
|
+
#
|
32
|
+
def highlighted_text
|
33
|
+
element.getAdditionalText()
|
34
|
+
end
|
35
|
+
|
22
36
|
end
|
23
37
|
end
|
@@ -117,7 +117,13 @@ module OperaWatir
|
|
117
117
|
end
|
118
118
|
|
119
119
|
alias_method :close_panel_with_click, :close_toolbar_with_click
|
120
|
-
|
120
|
+
|
121
|
+
######################################################################
|
122
|
+
# Clicks button to expand or collapse the toolbar
|
123
|
+
#
|
124
|
+
# @raise [DesktopExceptions::WidgetNotVisibleException] if the button
|
125
|
+
# is not visible
|
126
|
+
#
|
121
127
|
def expand_with_click
|
122
128
|
click
|
123
129
|
sleep(0.1)
|
@@ -8,7 +8,7 @@ module OperaWatir
|
|
8
8
|
end
|
9
9
|
|
10
10
|
######################################################################
|
11
|
-
#
|
11
|
+
# Switches to the dialog tab by clicking on it
|
12
12
|
#
|
13
13
|
# @raise [DesktopExceptions::WidgetNotVisibleException] if the dialogtab
|
14
14
|
# is not visible
|
@@ -8,7 +8,7 @@ module OperaWatir
|
|
8
8
|
end
|
9
9
|
|
10
10
|
######################################################################
|
11
|
-
#
|
11
|
+
# Sets focus to the edit field by clicking on it
|
12
12
|
#
|
13
13
|
# @raise [DesktopExceptions::WidgetNotVisibleException] if the editfield
|
14
14
|
# is not visible
|
@@ -24,17 +24,22 @@ module OperaWatir
|
|
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
|
27
|
+
# @param wait - seconds to wait after typing
|
27
28
|
#
|
28
29
|
# @return [String] contents of the edit field after typing has completed
|
29
30
|
#
|
30
|
-
def type_text(text)
|
31
|
+
def type_text(text, wait = 0)
|
31
32
|
text.each_char { | t | key_press_direct t }
|
32
33
|
|
33
34
|
# No event yet so just cheat and sleep
|
34
|
-
sleep(0.2)
|
35
|
+
sleep(0.2)
|
35
36
|
|
36
37
|
# Return what is in the field to check
|
37
|
-
element(true).getText
|
38
|
+
text = element(true).getText
|
39
|
+
|
40
|
+
sleep(wait) if wait != 0
|
41
|
+
|
42
|
+
text
|
38
43
|
end
|
39
44
|
|
40
45
|
######################################################################
|
@@ -8,7 +8,7 @@ module OperaWatir
|
|
8
8
|
end
|
9
9
|
|
10
10
|
######################################################################
|
11
|
-
# Drag and drop this speeddial
|
11
|
+
# Drag and drop this speeddial onto the speed dial tab_target
|
12
12
|
#
|
13
13
|
# @param [QuickThumbnail] Thumbnail to drop this thumbnail on
|
14
14
|
#
|
@@ -80,7 +80,7 @@ module OperaWatir
|
|
80
80
|
|
81
81
|
|
82
82
|
######################################################################
|
83
|
-
#
|
83
|
+
# Switches to the tree view tab by clicking on it (e.g. on the
|
84
84
|
# Advanced page of the preferences dialog)
|
85
85
|
#
|
86
86
|
# @raise [DesktopExceptions::WidgetNotVisibleException] if the treeitem
|
@@ -119,7 +119,7 @@ private
|
|
119
119
|
def scroll_item_into_view
|
120
120
|
|
121
121
|
# Make sure we have a window id
|
122
|
-
win_id = window_id >= 0 ? window_id : driver.
|
122
|
+
win_id = window_id >= 0 ? window_id : driver.getActiveQuickWindowID()
|
123
123
|
|
124
124
|
# Filter only treeitems in parent_treeview
|
125
125
|
treeitems = driver.getQuickWidgetList(win_id).select do |wdg|
|
@@ -8,8 +8,9 @@ module OperaWatir
|
|
8
8
|
end
|
9
9
|
|
10
10
|
#Should rather use what's already in browser
|
11
|
+
# @private
|
11
12
|
def treeitems
|
12
|
-
treeitems = driver.getQuickWidgetList(driver.
|
13
|
+
treeitems = driver.getQuickWidgetList(driver.getQuickWindowName(window_id)).map do |java_widget|
|
13
14
|
case java_widget.getType
|
14
15
|
when QuickWidget::WIDGET_ENUM_MAP[:treeitem]
|
15
16
|
QuickTreeItem.new(self,java_widget)
|
@@ -16,10 +16,14 @@ module OperaWatir
|
|
16
16
|
@selector = selector
|
17
17
|
@location = location
|
18
18
|
@window_id = window_id
|
19
|
-
#puts "Constructed widget #{@selector} inside #{@location} in window with id #{@window_id}"
|
20
19
|
end
|
21
20
|
end
|
22
21
|
|
22
|
+
#######################################################################
|
23
|
+
#
|
24
|
+
# Hovers widget and waits for window to be shown
|
25
|
+
#
|
26
|
+
#
|
23
27
|
def open_window_with_hover(win_name = "")
|
24
28
|
wait_start
|
25
29
|
element.hover
|
@@ -63,7 +67,7 @@ module OperaWatir
|
|
63
67
|
end
|
64
68
|
|
65
69
|
######################################################################
|
66
|
-
#
|
70
|
+
# Gets the text of the widget
|
67
71
|
#
|
68
72
|
# @note This method should not be used to check the text in a widget if
|
69
73
|
# the text is in the Opera language file. Use verify_text or
|
@@ -91,7 +95,7 @@ module OperaWatir
|
|
91
95
|
end
|
92
96
|
|
93
97
|
######################################################################
|
94
|
-
#
|
98
|
+
# Gets the name of the widget (as it appears in dialog.ini or code)
|
95
99
|
#
|
96
100
|
# @return [String] name of the widget
|
97
101
|
#
|
@@ -103,7 +107,7 @@ module OperaWatir
|
|
103
107
|
end
|
104
108
|
|
105
109
|
######################################################################
|
106
|
-
#
|
110
|
+
# Gets a string representation of the widget
|
107
111
|
#
|
108
112
|
# @return [String] representation of the widget
|
109
113
|
#
|
@@ -111,7 +115,7 @@ module OperaWatir
|
|
111
115
|
# using the specified method
|
112
116
|
#
|
113
117
|
def to_s
|
114
|
-
"#{type.to_s.capitalize} #{name},
|
118
|
+
"#{type.to_s.capitalize} #{name}, text=#{text}, parentName=#{parent_name}, visible=#{visible?}, enabled=#{enabled?}, position=#{row},#{col}"
|
115
119
|
end
|
116
120
|
|
117
121
|
######################################################################
|
@@ -157,13 +161,29 @@ module OperaWatir
|
|
157
161
|
# @raise [Exceptions::UnknownObjectException] if the widget cannot be found
|
158
162
|
# using the specified method
|
159
163
|
#
|
164
|
+
#@private
|
160
165
|
def print_row
|
166
|
+
puts row_info_string
|
167
|
+
end
|
168
|
+
|
169
|
+
######################################################################
|
170
|
+
# Prints out all of the row/col information in single lines. Used to
|
171
|
+
# check items from lists
|
172
|
+
#
|
173
|
+
# @raise [Exceptions::UnknownObjectException] if the widget cannot be found
|
174
|
+
# using the specified method
|
175
|
+
#@private
|
176
|
+
def row_info_string
|
161
177
|
if element.getColumn() == 0
|
162
|
-
|
178
|
+
"Parent: " + element.getParentName() + ", Item: " + element.getRow().to_s + ", Text: " + text
|
163
179
|
end
|
180
|
+
""
|
164
181
|
end
|
165
182
|
|
183
|
+
########################################################################
|
184
|
+
#
|
166
185
|
# @return position for elements that have a position, else false
|
186
|
+
#
|
167
187
|
def position
|
168
188
|
return [row, col] if type == :treeitem
|
169
189
|
return col if type == :tabbutton
|
@@ -176,19 +196,29 @@ module OperaWatir
|
|
176
196
|
#
|
177
197
|
# @raise [Exceptions::UnknownObjectException] if the widget cannot be found
|
178
198
|
# using the specified method
|
179
|
-
|
199
|
+
#@private
|
180
200
|
def print_widget_info
|
181
|
-
puts
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
201
|
+
puts widget_info_string
|
202
|
+
end
|
203
|
+
|
204
|
+
######################################################################
|
205
|
+
# Returns a string of all of the internal information about the widget. Used
|
206
|
+
# to discover the names of widgets and windows to use in the tests
|
207
|
+
#
|
208
|
+
# @raise [Exceptions::UnknownObjectException] if the widget cannot be found
|
209
|
+
# using the specified method
|
210
|
+
#
|
211
|
+
def widget_info_string
|
212
|
+
" Name: " + name +
|
213
|
+
"\n Text: " + text +
|
214
|
+
"\n Type: " + type.to_s +
|
215
|
+
"\n Parent: " + element.getParentName() +
|
216
|
+
"\nVisible: " + visible?.to_s +
|
217
|
+
"\nEnabled: " + enabled?.to_s +
|
218
|
+
"\n Pos: x=" + element.getRect().x.to_s + ", y=" + element.getRect().y.to_s +
|
219
|
+
"\n Size: width=" + element.getRect().width.to_s + ", height=" + element.getRect().height.to_s +
|
220
|
+
"\n Ref: row=" + element.getRow().to_s + ", col=" + element.getColumn().to_s +
|
221
|
+
"\nselected: " + element.isSelected().to_s + "\n"
|
192
222
|
end
|
193
223
|
|
194
224
|
# @private
|
@@ -196,13 +226,14 @@ module OperaWatir
|
|
196
226
|
@container.driver
|
197
227
|
end
|
198
228
|
|
199
|
-
# parent
|
200
|
-
# Get parent widget name
|
229
|
+
# Gets parent widget name
|
201
230
|
def parent_name
|
202
231
|
element.getParentName()
|
203
232
|
end
|
204
233
|
|
234
|
+
#################################################################
|
205
235
|
# Focus a widget with a click
|
236
|
+
#
|
206
237
|
def focus_with_click
|
207
238
|
click
|
208
239
|
# No event yet so just cheat and sleep
|
@@ -282,7 +313,6 @@ private
|
|
282
313
|
|
283
314
|
# Dialog tabs are always visible even if the page they are connected to isn't
|
284
315
|
if visible? == true or type == :dialogtab
|
285
|
-
#DesktopEnums::KEYMODIFIER_ENUM_MAP.each { |k, v| puts "#{k},#{v}"}
|
286
316
|
button = DesktopEnums::MOUSEBUTTON_ENUM_MAP[button]
|
287
317
|
list = Java::JavaUtil::ArrayList.new
|
288
318
|
opts.each { |mod| list << DesktopEnums::KEYMODIFIER_ENUM_MAP[mod] }
|
@@ -6,7 +6,7 @@ module OperaWatir
|
|
6
6
|
# @private
|
7
7
|
def initialize(container, method, selector=nil)
|
8
8
|
@container = container
|
9
|
-
|
9
|
+
|
10
10
|
if method.is_a? Java::ComOperaCoreSystems::QuickWindow
|
11
11
|
@elm = method
|
12
12
|
else
|
@@ -16,7 +16,7 @@ module OperaWatir
|
|
16
16
|
end
|
17
17
|
|
18
18
|
######################################################################
|
19
|
-
# Checks whether a
|
19
|
+
# Checks whether a window exists or not
|
20
20
|
#
|
21
21
|
# @return [Boolean] true if the widget exists otherwise false
|
22
22
|
#
|
@@ -28,7 +28,7 @@ module OperaWatir
|
|
28
28
|
alias_method :exists?, :exist?
|
29
29
|
|
30
30
|
######################################################################
|
31
|
-
# Gets the type of a
|
31
|
+
# Gets the type of a window
|
32
32
|
#
|
33
33
|
# @return [Symbol] type of the window (e.g. :dropdown, :button)
|
34
34
|
#
|
@@ -38,7 +38,7 @@ module OperaWatir
|
|
38
38
|
end
|
39
39
|
|
40
40
|
######################################################################
|
41
|
-
#
|
41
|
+
# Gets the name of the window
|
42
42
|
#
|
43
43
|
# @return [String] name of the widget
|
44
44
|
#
|
@@ -49,7 +49,7 @@ module OperaWatir
|
|
49
49
|
end
|
50
50
|
|
51
51
|
######################################################################
|
52
|
-
#
|
52
|
+
# Gets the title of the window
|
53
53
|
#
|
54
54
|
# @return [String] title of window
|
55
55
|
#
|
@@ -61,7 +61,7 @@ module OperaWatir
|
|
61
61
|
|
62
62
|
|
63
63
|
######################################################################
|
64
|
-
#
|
64
|
+
# Gets a string representation of the window
|
65
65
|
#
|
66
66
|
# @return [String] representation of the widget
|
67
67
|
#
|
@@ -81,10 +81,8 @@ module OperaWatir
|
|
81
81
|
element.isOnScreen
|
82
82
|
end
|
83
83
|
|
84
|
-
alias_method :visible?, :on_screen?
|
85
|
-
|
86
84
|
######################################################################
|
87
|
-
#
|
85
|
+
# Gets this windows window id
|
88
86
|
#
|
89
87
|
# @return [int] the windows window_id
|
90
88
|
#
|
@@ -98,19 +96,29 @@ module OperaWatir
|
|
98
96
|
|
99
97
|
######################################################################
|
100
98
|
# Prints out all of the internal information about the window. Used
|
101
|
-
# to discover the names of widgets and windows to use in the tests
|
99
|
+
# to discover the names of widgets and windows to use in the tests.
|
102
100
|
#
|
103
101
|
# @raise [Exceptions::UnknownObjectException] if the widget could not be found
|
104
102
|
# using the specified method
|
103
|
+
#@private
|
105
104
|
def print_window_info
|
106
|
-
puts
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
105
|
+
puts window_info_string
|
106
|
+
end
|
107
|
+
|
108
|
+
######################################################################
|
109
|
+
# Returns a string of the internal information about the window. Used
|
110
|
+
# to discover the names of widgets and windows to use in the tests.
|
111
|
+
#
|
112
|
+
# @raise [Exceptions::UnknownObjectException] if the widget could not be found
|
113
|
+
# using the specified method
|
114
|
+
def window_info_string
|
115
|
+
" Name: " + name +
|
116
|
+
"\n Title: " + title +
|
117
|
+
"\n ID: " + id.to_s +
|
118
|
+
"\n Type: " + type.to_s +
|
119
|
+
"\nOnScreen: " + on_screen?.to_s +
|
120
|
+
"\n Pos: x=" + element.getRect().x.to_s + ", y=" + element.getRect().y.to_s +
|
121
|
+
"\n Size: width=" + element.getRect().width.to_s + ", height=" + element.getRect().height.to_s + "\n"
|
114
122
|
end
|
115
123
|
|
116
124
|
# @private
|
@@ -137,9 +145,16 @@ private
|
|
137
145
|
|
138
146
|
# Finds the element on the page.
|
139
147
|
def find
|
148
|
+
#puts "<find> Find Window by " + @method.to_s + ", selector = " + @selector.to_s
|
140
149
|
case @method
|
141
150
|
when :name
|
142
|
-
|
151
|
+
# 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")
|
154
|
+
@element = driver.findWindowById(driver.getActiveQuickWindowID())
|
155
|
+
else
|
156
|
+
@element = driver.findWindowByName(@selector)
|
157
|
+
end
|
143
158
|
when :id
|
144
159
|
@element = driver.findWindowById(@selector)
|
145
160
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
class OperaWatir::Spatnav
|
3
|
+
|
4
|
+
attr_accessor :browser
|
5
|
+
|
6
|
+
def initialize(browser)
|
7
|
+
self.browser = browser
|
8
|
+
end
|
9
|
+
|
10
|
+
# FIXME: These should be implemented as proper methods in
|
11
|
+
# OperaDriver.
|
12
|
+
|
13
|
+
def up
|
14
|
+
driver.operaAction('Navigate up')
|
15
|
+
end
|
16
|
+
|
17
|
+
def down
|
18
|
+
driver.operaAction('Navigate down')
|
19
|
+
end
|
20
|
+
|
21
|
+
def left
|
22
|
+
driver.operaAction('Navigate left')
|
23
|
+
end
|
24
|
+
|
25
|
+
def right
|
26
|
+
driver.operaAction('Navigate right')
|
27
|
+
end
|
28
|
+
|
29
|
+
def activate
|
30
|
+
driver.operaAction('Activate element')
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
def driver
|
35
|
+
browser.driver
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|