celerity 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +15 -1
- data/Manifest.txt +174 -0
- data/README.txt +19 -10
- data/config/hoe.rb +68 -0
- data/config/requirements.rb +15 -0
- data/lib/celerity.rb +14 -11
- data/lib/celerity/collections.rb +37 -8
- data/lib/celerity/container.rb +100 -3
- data/lib/celerity/disabled_element.rb +4 -2
- data/lib/celerity/element.rb +21 -8
- data/lib/celerity/element_collections.rb +4 -7
- data/lib/celerity/element_locator.rb +1 -0
- data/lib/celerity/elements/button.rb +6 -2
- data/lib/celerity/elements/file_field.rb +1 -1
- data/lib/celerity/elements/form.rb +1 -2
- data/lib/celerity/elements/frame.rb +0 -3
- data/lib/celerity/elements/image.rb +1 -4
- data/lib/celerity/elements/label.rb +1 -0
- data/lib/celerity/elements/link.rb +2 -0
- data/lib/celerity/elements/option.rb +1 -0
- data/lib/celerity/elements/radio_check.rb +3 -5
- data/lib/celerity/elements/select_list.rb +3 -10
- data/lib/celerity/elements/table.rb +8 -22
- data/lib/celerity/elements/table_body.rb +5 -11
- data/lib/celerity/elements/table_cell.rb +1 -0
- data/lib/celerity/elements/table_footer.rb +30 -0
- data/lib/celerity/elements/table_header.rb +30 -0
- data/lib/celerity/elements/table_row.rb +5 -3
- data/lib/celerity/elements/text_field.rb +18 -13
- data/lib/celerity/exception.rb +8 -8
- data/lib/celerity/extra/method_generator.rb +5 -2
- data/lib/celerity/htmlunit/htmlunit-2.2-SNAPSHOT.jar +0 -0
- data/lib/celerity/ie.rb +195 -141
- data/lib/celerity/non_control_elements.rb +30 -4
- data/lib/celerity/version.rb +1 -1
- data/lib/celerity/watir_compatibility.rb +62 -0
- data/setup.rb +0 -2
- data/spec/area_spec.rb +4 -1
- data/spec/areas_spec.rb +1 -1
- data/spec/button_spec.rb +35 -17
- data/spec/buttons_spec.rb +1 -1
- data/spec/checkbox_spec.rb +6 -4
- data/spec/checkboxes_spec.rb +1 -1
- data/spec/div_spec.rb +20 -19
- data/spec/divs_spec.rb +2 -2
- data/spec/element_spec.rb +13 -2
- data/spec/filefield_spec.rb +6 -3
- data/spec/filefields_spec.rb +1 -1
- data/spec/form_spec.rb +4 -1
- data/spec/forms_spec.rb +1 -1
- data/spec/frame_spec.rb +6 -2
- data/spec/hidden_spec.rb +8 -4
- data/spec/hiddens_spec.rb +1 -1
- data/spec/hn_spec.rb +86 -0
- data/spec/hns_spec.rb +41 -0
- data/spec/html/bug_duplicate_attributes.html +14 -0
- data/spec/html/bug_javascript_001.html +11 -0
- data/spec/html/forms_with_input_elements.html +11 -11
- data/spec/html/images.html +18 -15
- data/spec/html/latin1_text.html +16 -0
- data/spec/html/non_control_elements.html +28 -4
- data/spec/html/tables.html +3 -3
- data/spec/html/utf8_text.html +15 -0
- data/spec/htmlunit_spec.rb +27 -0
- data/spec/ie_spec.rb +47 -12
- data/spec/image_spec.rb +4 -7
- data/spec/images_spec.rb +3 -2
- data/spec/label_spec.rb +4 -3
- data/spec/labels_spec.rb +1 -1
- data/spec/li_spec.rb +11 -8
- data/spec/link_spec.rb +5 -1
- data/spec/links_spec.rb +2 -1
- data/spec/lis_spec.rb +3 -2
- data/spec/map_spec.rb +4 -1
- data/spec/maps_spec.rb +1 -1
- data/spec/meta_spec.rb +6 -0
- data/spec/ol_spec.rb +73 -0
- data/spec/ols_spec.rb +41 -0
- data/spec/option_spec.rb +129 -0
- data/spec/p_spec.rb +4 -1
- data/spec/pre_spec.rb +4 -1
- data/spec/pres_spec.rb +1 -1
- data/spec/ps_spec.rb +2 -1
- data/spec/radio_spec.rb +7 -19
- data/spec/radios_spec.rb +1 -1
- data/spec/select_list_spec.rb +19 -57
- data/spec/select_lists_spec.rb +3 -2
- data/spec/span_spec.rb +8 -5
- data/spec/spans_spec.rb +2 -1
- data/spec/spec_helper.rb +8 -43
- data/spec/table_bodies_spec.rb +17 -4
- data/spec/table_body_spec.rb +47 -16
- data/spec/table_cell_spec.rb +5 -3
- data/spec/table_cells_spec.rb +1 -1
- data/spec/table_footer_spec.rb +94 -0
- data/spec/table_footers_spec.rb +53 -0
- data/spec/table_header_spec.rb +94 -0
- data/spec/table_headers_spec.rb +53 -0
- data/spec/table_row_spec.rb +25 -4
- data/spec/table_rows_spec.rb +1 -1
- data/spec/table_spec.rb +22 -2
- data/spec/tables_spec.rb +2 -1
- data/spec/text_field_spec.rb +52 -20
- data/spec/text_fields_spec.rb +1 -1
- data/spec/ul_spec.rb +73 -0
- data/spec/uls_spec.rb +41 -0
- data/spec/watir_compatability_spec.rb +253 -0
- data/support/celerity_viewer/rubycocoa/CelerityViewer.icns +0 -0
- data/support/celerity_viewer/rubycocoa/English.lproj/Main.nib/classes.nib +37 -0
- data/support/celerity_viewer/rubycocoa/English.lproj/Main.nib/info.nib +19 -0
- data/support/celerity_viewer/rubycocoa/English.lproj/Main.nib/keyedobjects.nib +0 -0
- data/support/celerity_viewer/rubycocoa/Info.plist.erb +28 -0
- data/support/celerity_viewer/rubycocoa/MainController.rb +23 -0
- data/support/celerity_viewer/rubycocoa/README +94 -0
- data/support/celerity_viewer/rubycocoa/Rakefile +100 -0
- data/support/celerity_viewer/rubycocoa/distributed_viewer.rb +86 -0
- data/support/celerity_viewer/rubycocoa/main.m +7 -0
- data/support/celerity_viewer/rubycocoa/main.rb +27 -0
- data/support/spec_server.rb +64 -0
- data/tasks/benchmark.rake +1 -0
- data/tasks/rdoc.rake +4 -0
- data/tasks/rspec.rake +10 -3
- data/tasks/simple_ci.rake +94 -0
- data/tasks/specserver.rake +21 -0
- metadata +160 -114
- data/spec/table_bodies.rb +0 -40
- data/tasks/testserver.rake +0 -32
data/lib/celerity/container.rb
CHANGED
@@ -25,6 +25,34 @@ module Celerity
|
|
25
25
|
assert_exists
|
26
26
|
Tables.new(self)
|
27
27
|
end
|
28
|
+
|
29
|
+
def thead(*args)
|
30
|
+
assert_exists
|
31
|
+
TableHeader.new(self, *args)
|
32
|
+
end
|
33
|
+
def theads
|
34
|
+
assert_exists
|
35
|
+
TableHeaders.new(self)
|
36
|
+
end
|
37
|
+
|
38
|
+
def tbody(*args)
|
39
|
+
assert_exists
|
40
|
+
TableBody.new(self, *args)
|
41
|
+
end
|
42
|
+
def tbodies
|
43
|
+
assert_exists
|
44
|
+
TableBodies.new(self)
|
45
|
+
end
|
46
|
+
|
47
|
+
def tfoot(*args)
|
48
|
+
assert_exists
|
49
|
+
TableFooter.new(self, *args)
|
50
|
+
end
|
51
|
+
def tfoots
|
52
|
+
assert_exists
|
53
|
+
TableFooters.new(self)
|
54
|
+
end
|
55
|
+
alias_method :tfeet, :tfoots # :-)
|
28
56
|
|
29
57
|
def cell(*args)
|
30
58
|
assert_exists
|
@@ -88,13 +116,16 @@ module Celerity
|
|
88
116
|
assert_exists
|
89
117
|
SelectLists.new(self)
|
90
118
|
end
|
119
|
+
|
120
|
+
def option(*args)
|
121
|
+
assert_exists
|
122
|
+
Option.new(self, *args)
|
123
|
+
end
|
91
124
|
|
92
125
|
def check_box(*args)
|
93
126
|
assert_exists
|
94
127
|
CheckBox.new(self, *args)
|
95
128
|
end
|
96
|
-
alias_method :checkbox, :check_box
|
97
|
-
alias_method :checkBox, :check_box
|
98
129
|
|
99
130
|
def checkboxes
|
100
131
|
assert_exists
|
@@ -119,6 +150,24 @@ module Celerity
|
|
119
150
|
assert_exists
|
120
151
|
Links.new(self)
|
121
152
|
end
|
153
|
+
|
154
|
+
def ul(*args)
|
155
|
+
assert_exists
|
156
|
+
Ul.new(self, *args)
|
157
|
+
end
|
158
|
+
def uls
|
159
|
+
assert_exists
|
160
|
+
Uls.new(self)
|
161
|
+
end
|
162
|
+
|
163
|
+
def ol(*args)
|
164
|
+
assert_exists
|
165
|
+
Ol.new(self, *args)
|
166
|
+
end
|
167
|
+
def ols
|
168
|
+
assert_exists
|
169
|
+
Ols.new(self)
|
170
|
+
end
|
122
171
|
|
123
172
|
def li(*args)
|
124
173
|
assert_exists
|
@@ -160,7 +209,6 @@ module Celerity
|
|
160
209
|
assert_exists
|
161
210
|
Div.new(self, *args)
|
162
211
|
end
|
163
|
-
|
164
212
|
def divs
|
165
213
|
assert_exists
|
166
214
|
Divs.new(self)
|
@@ -210,6 +258,55 @@ module Celerity
|
|
210
258
|
assert_exists
|
211
259
|
Labels.new(self)
|
212
260
|
end
|
261
|
+
|
262
|
+
def h1(*args)
|
263
|
+
assert_exists
|
264
|
+
H1.new(self, *args)
|
265
|
+
end
|
266
|
+
def h2(*args)
|
267
|
+
assert_exists
|
268
|
+
H2.new(self, *args)
|
269
|
+
end
|
270
|
+
def h3(*args)
|
271
|
+
assert_exists
|
272
|
+
H3.new(self, *args)
|
273
|
+
end
|
274
|
+
def h4(*args)
|
275
|
+
assert_exists
|
276
|
+
H4.new(self, *args)
|
277
|
+
end
|
278
|
+
def h5(*args)
|
279
|
+
assert_exists
|
280
|
+
H5.new(self, *args)
|
281
|
+
end
|
282
|
+
def h6(*args)
|
283
|
+
assert_exists
|
284
|
+
H6.new(self, *args)
|
285
|
+
end
|
286
|
+
def h1s
|
287
|
+
assert_exists
|
288
|
+
H1s.new(self)
|
289
|
+
end
|
290
|
+
def h2s
|
291
|
+
assert_exists
|
292
|
+
H2s.new(self)
|
293
|
+
end
|
294
|
+
def h3s
|
295
|
+
assert_exists
|
296
|
+
H3s.new(self)
|
297
|
+
end
|
298
|
+
def h4s
|
299
|
+
assert_exists
|
300
|
+
H4s.new(self)
|
301
|
+
end
|
302
|
+
def h5s
|
303
|
+
assert_exists
|
304
|
+
H5s.new(self)
|
305
|
+
end
|
306
|
+
def h6s
|
307
|
+
assert_exists
|
308
|
+
H6s.new(self)
|
309
|
+
end
|
213
310
|
|
214
311
|
private
|
215
312
|
|
@@ -1,18 +1,20 @@
|
|
1
1
|
module Celerity
|
2
2
|
module DisabledElement
|
3
|
+
include Celerity::Exception
|
4
|
+
|
3
5
|
def enabled?
|
4
6
|
!disabled?
|
5
7
|
end
|
6
8
|
|
7
9
|
def disabled?
|
8
|
-
assert_exists unless @object
|
10
|
+
assert_exists unless defined?(@object) && @object
|
9
11
|
@object.isDisabled
|
10
12
|
end
|
11
13
|
alias_method :disabled, :disabled?
|
12
14
|
|
13
15
|
def assert_enabled
|
14
16
|
if disabled?
|
15
|
-
raise ObjectDisabledException, "Object #{
|
17
|
+
raise ObjectDisabledException, "Object #{identifier_string} is disabled"
|
16
18
|
end
|
17
19
|
end
|
18
20
|
|
data/lib/celerity/element.rb
CHANGED
@@ -9,10 +9,10 @@ module Celerity
|
|
9
9
|
|
10
10
|
# HTML 4.01 Transitional DTD
|
11
11
|
HTML_401_TRANSITIONAL = {
|
12
|
-
:core => [:class, :id, :style, :title],
|
12
|
+
:core => [:class, :id, :style, :title],
|
13
13
|
:cell_halign => [:align, :char, :charoff],
|
14
14
|
:cell_valign => [:valign],
|
15
|
-
:i18n => [:dir, :lang],
|
15
|
+
:i18n => [:dir, :lang],
|
16
16
|
:event => [:onclick, :ondblclick, :onmousedown, :onmouseup, :onmouseover, :onmousemove, :onmouseout, :onkeypress, :onkeydown, :onkeyup],
|
17
17
|
:sloppy => [:name, :value]
|
18
18
|
}
|
@@ -27,27 +27,29 @@ module Celerity
|
|
27
27
|
|
28
28
|
case args.size
|
29
29
|
when 2
|
30
|
-
@conditions = {args[0] => args[1]}
|
30
|
+
@conditions = { args[0] => args[1] }
|
31
31
|
when 1
|
32
32
|
if Hash === args.first
|
33
33
|
@conditions = args.first
|
34
|
-
elsif
|
35
|
-
@conditions = {self.class::DEFAULT_HOW => args.first}
|
34
|
+
elsif self.class::DEFAULT_HOW
|
35
|
+
@conditions = { self.class::DEFAULT_HOW => args.first }
|
36
36
|
else
|
37
37
|
raise ArgumentError, "wrong number of arguments (1 for 2)"
|
38
38
|
end
|
39
|
+
else
|
40
|
+
raise ArgumentError, "wrong number of arguments (#{args.size} for 2)"
|
39
41
|
end
|
40
42
|
end
|
41
43
|
|
42
44
|
def locate
|
43
|
-
@object
|
45
|
+
@object = ElementLocator.new(@container.object, self.class).find_by_conditions(@conditions)
|
44
46
|
end
|
45
47
|
|
46
48
|
def to_s
|
47
49
|
assert_exists
|
48
50
|
create_string(@object)
|
49
51
|
end
|
50
|
-
|
52
|
+
|
51
53
|
def attribute_value(attribute)
|
52
54
|
assert_exists
|
53
55
|
@object.getAttribute(attribute)
|
@@ -117,6 +119,17 @@ module Celerity
|
|
117
119
|
super
|
118
120
|
end
|
119
121
|
end
|
122
|
+
|
123
|
+
def attribute_string
|
124
|
+
assert_exists
|
125
|
+
n = ''
|
126
|
+
iterator = @object.getAttributeEntriesIterator
|
127
|
+
while iterator.hasNext
|
128
|
+
attribute = iterator.next
|
129
|
+
n += "#{attribute.getName}=\"#{attribute.getHtmlValue.to_s}\" "
|
130
|
+
end
|
131
|
+
return n
|
132
|
+
end
|
120
133
|
|
121
134
|
private
|
122
135
|
|
@@ -124,7 +137,7 @@ module Celerity
|
|
124
137
|
n = []
|
125
138
|
n << "tag:".ljust(TO_S_SIZE) + element.getTagName unless element.getTagName.empty?
|
126
139
|
iterator = element.getAttributeEntriesIterator
|
127
|
-
while
|
140
|
+
while iterator.hasNext
|
128
141
|
attribute = iterator.next
|
129
142
|
n << " #{attribute.getName}:".ljust(TO_S_SIZE+2) + attribute.getHtmlValue.to_s
|
130
143
|
end
|
@@ -7,13 +7,9 @@ module Celerity
|
|
7
7
|
def initialize(container, how = nil, what = nil)
|
8
8
|
@container = container
|
9
9
|
@object = (how == :object ? what : nil)
|
10
|
-
@length = length
|
10
|
+
@length = length
|
11
11
|
end
|
12
12
|
|
13
|
-
def element_tags
|
14
|
-
element_class::TAGS
|
15
|
-
end
|
16
|
-
|
17
13
|
def length
|
18
14
|
if @object
|
19
15
|
@object.length
|
@@ -27,13 +23,14 @@ module Celerity
|
|
27
23
|
def each
|
28
24
|
if @elements
|
29
25
|
@elements.each { |e| yield(element_class.new(@container, :object, e)) }
|
26
|
+
@length
|
30
27
|
else
|
31
28
|
0.upto(@length - 1) { |i| yield iterator_object(i) }
|
32
29
|
end
|
33
30
|
end
|
34
31
|
|
35
32
|
def [](n)
|
36
|
-
@elements ? element_class.new(@container, :object, @elements[n - 1]) : iterator_object(n-1)
|
33
|
+
@elements ? element_class.new(@container, :object, @elements[n - 1]) : iterator_object(n - 1)
|
37
34
|
end
|
38
35
|
|
39
36
|
def to_s
|
@@ -44,7 +41,7 @@ module Celerity
|
|
44
41
|
|
45
42
|
# this method creates an object of the correct type that the iterators use
|
46
43
|
def iterator_object(i)
|
47
|
-
element_class.new(@container, :index, i+1)
|
44
|
+
element_class.new(@container, :index, i + 1)
|
48
45
|
end
|
49
46
|
|
50
47
|
end # ElementCollections
|
@@ -7,17 +7,21 @@ module Celerity
|
|
7
7
|
class Button < InputElement
|
8
8
|
TAGS = [ Identifier.new('button'),
|
9
9
|
Identifier.new('input', :type => %w(submit reset image button)) ]
|
10
|
+
# A little wierd attribute list due to button being both <button> and <input type="submit|reset|image|button" />
|
11
|
+
ATTRIBUTES = BASE_ATTRIBUTES | [:type, :disabled, :tabindex, :accesskey, :onfocus, :onblur] | [:src, :usemap, :ismap]
|
10
12
|
DEFAULT_HOW = :value
|
11
13
|
|
12
14
|
def locate
|
13
15
|
# ugly..
|
14
|
-
if (val = @conditions
|
16
|
+
if (val = @conditions[:value])
|
15
17
|
locator = ElementLocator.new(@container.object, self.class)
|
16
18
|
button_ident = Identifier.new('button')
|
17
19
|
button_ident.text = val
|
18
20
|
input_ident = Identifier.new('input', :type => %w(submit reset image button), :value => [val])
|
19
21
|
locator.idents = [button_ident, input_ident]
|
20
|
-
|
22
|
+
conditions = @conditions.dup
|
23
|
+
conditions.delete(:value)
|
24
|
+
@object = locator.find_by_conditions(conditions)
|
21
25
|
else
|
22
26
|
super
|
23
27
|
end
|
@@ -2,10 +2,10 @@ module Celerity
|
|
2
2
|
# For fields that accept file uploads
|
3
3
|
class FileField < InputElement
|
4
4
|
TAGS = [ Identifier.new('input', :type => %w(file)) ]
|
5
|
+
DEFAULT_HOW = :name
|
5
6
|
|
6
7
|
def set(value)
|
7
8
|
assert_exists
|
8
|
-
# TODO: trigger events?
|
9
9
|
@object.setValueAttribute(value.to_s)
|
10
10
|
end
|
11
11
|
end
|
@@ -4,7 +4,6 @@ module Celerity
|
|
4
4
|
attr_accessor :page
|
5
5
|
|
6
6
|
TAGS = [Identifier.new('frame'), Identifier.new('iframe')]
|
7
|
-
|
8
7
|
ATTRIBUTES = BASE_ATTRIBUTES | [:longdesc, :name, :src, :frameborder, :marginwidth, :marginheight, :noresize, :scrolling]
|
9
8
|
DEFAULT_HOW = :name
|
10
9
|
|
@@ -14,8 +13,6 @@ module Celerity
|
|
14
13
|
@inline_frame_object = @object.getEnclosedWindow.getFrameElement
|
15
14
|
if (frame = @object.getEnclosedPage.getDocumentElement)
|
16
15
|
@object = frame
|
17
|
-
else
|
18
|
-
@object = nil
|
19
16
|
end
|
20
17
|
end
|
21
18
|
end
|
@@ -11,6 +11,7 @@ module Celerity
|
|
11
11
|
|
12
12
|
TAGS = [ Identifier.new('img') ]
|
13
13
|
ATTRIBUTES = BASE_ATTRIBUTES | [:src, :alt, :longdesc, :name, :height, :width, :usemap, :ismap, :align, :border, :hspace, :vspace]
|
14
|
+
DEFAULT_HOW = :src
|
14
15
|
|
15
16
|
# this method returns the file created date of the image
|
16
17
|
def file_created_date
|
@@ -18,7 +19,6 @@ module Celerity
|
|
18
19
|
web_response = @object.getWebResponse(true)
|
19
20
|
return Time.parse(web_response.getResponseHeaderValue("Last-Modified").to_s)
|
20
21
|
end
|
21
|
-
alias_method :fileCreatedDate, :file_created_date
|
22
22
|
|
23
23
|
# this method returns the filesize of the image
|
24
24
|
def file_size
|
@@ -26,7 +26,6 @@ module Celerity
|
|
26
26
|
web_response = @object.getWebResponse(true)
|
27
27
|
return web_response.getResponseBody().length
|
28
28
|
end
|
29
|
-
alias_method :fileSize, :file_size
|
30
29
|
|
31
30
|
# returns the width in pixels of the image, as a string
|
32
31
|
def width
|
@@ -49,8 +48,6 @@ module Celerity
|
|
49
48
|
return false
|
50
49
|
end
|
51
50
|
end
|
52
|
-
alias_method :hasLoaded?, :loaded?
|
53
|
-
alias_method :has_loaded?, :loaded?
|
54
51
|
|
55
52
|
def save(filename)
|
56
53
|
assert_exists
|
@@ -1,7 +1,9 @@
|
|
1
1
|
module Celerity
|
2
2
|
class Link < Element
|
3
|
+
|
3
4
|
TAGS = [ Identifier.new('a') ]
|
4
5
|
ATTRIBUTES = BASE_ATTRIBUTES | [:charset, :type, :name, :href, :hreflang, :target, :rel, :rev, :accesskey, :shape, :coords, :tabindex, :onfocus, :onblur]
|
6
|
+
DEFAULT_HOW = :href
|
5
7
|
|
6
8
|
def click
|
7
9
|
assert_exists
|
@@ -6,9 +6,10 @@ module Celerity
|
|
6
6
|
# most of the methods available to this element are inherited from the Element class
|
7
7
|
#
|
8
8
|
class RadioCheckCommon < InputElement
|
9
|
+
DEFAULT_HOW = :name
|
10
|
+
|
9
11
|
def initialize(container, type, *args)
|
10
12
|
@type = type
|
11
|
-
|
12
13
|
case args.size
|
13
14
|
when 2
|
14
15
|
super(container, args[0] => args[1])
|
@@ -23,10 +24,6 @@ module Celerity
|
|
23
24
|
assert_exists
|
24
25
|
@object.isChecked
|
25
26
|
end
|
26
|
-
alias_method :is_set?, :set?
|
27
|
-
alias_method :isSet?, :set?
|
28
|
-
alias_method :get_state, :set?
|
29
|
-
alias_method :getState, :set?
|
30
27
|
alias_method :checked?, :set?
|
31
28
|
|
32
29
|
def clear
|
@@ -62,6 +59,7 @@ module Celerity
|
|
62
59
|
assert_exists
|
63
60
|
assert_enabled
|
64
61
|
if (value && !set?) || (!value && set?)
|
62
|
+
Log.debug(@object.inspect)
|
65
63
|
@container.update_page(@object.click)
|
66
64
|
end
|
67
65
|
end
|
@@ -6,24 +6,22 @@ module Celerity
|
|
6
6
|
# Normally a user would not need to create this object as it is returned by the Watir::Container#select_list method
|
7
7
|
class SelectList < InputElement
|
8
8
|
TAGS = [ Identifier.new('select') ]
|
9
|
+
DEFAULT_HOW = :name
|
9
10
|
|
10
11
|
def get_all_contents
|
11
12
|
assert_exists
|
12
13
|
@object.getOptions.map { |e| e.asText }
|
13
14
|
end
|
14
|
-
alias_method :getAllContents, :get_all_contents
|
15
15
|
|
16
16
|
def get_selected_items
|
17
17
|
assert_exists
|
18
18
|
@object.getSelectedOptions.map { |e| e.asText }
|
19
19
|
end
|
20
|
-
alias_method :getSelectedItems, :get_selected_items
|
21
20
|
|
22
21
|
def clear_selection
|
23
22
|
# assert_exists called by SelectList#type here
|
24
23
|
@object.getSelectedOptions.each { |e| e.setSelected(false) } unless type() == 'select-one'
|
25
24
|
end
|
26
|
-
alias_method :clearSelection, :clear_selection
|
27
25
|
|
28
26
|
def select(value)
|
29
27
|
assert_exists
|
@@ -32,7 +30,6 @@ module Celerity
|
|
32
30
|
@container.update_page(option.click)
|
33
31
|
end
|
34
32
|
end
|
35
|
-
alias_method :select_value, :select
|
36
33
|
alias_method :set, :select
|
37
34
|
|
38
35
|
def include?(value)
|
@@ -43,11 +40,11 @@ module Celerity
|
|
43
40
|
|
44
41
|
def selected?(value)
|
45
42
|
assert_exists
|
46
|
-
# This should probably raise NoValueFoundException?
|
47
43
|
raise UnknownObjectException, "unknown option with value #{value.inspect}" unless include?(value)
|
48
44
|
!!@object.getOptions.find { |e| matches?(e.asText, value) && e.isSelected }
|
49
45
|
end
|
50
46
|
|
47
|
+
# TODO: Move to watir_compatibility or delete it 2008-05-23 Alexander
|
51
48
|
def type
|
52
49
|
assert_exists
|
53
50
|
'select-' + (@object.isAttributeDefined('multiple') ? 'multiple' : 'one')
|
@@ -59,10 +56,6 @@ module Celerity
|
|
59
56
|
optn.getValueAttribute
|
60
57
|
end
|
61
58
|
end
|
62
|
-
|
63
|
-
def option(attribute, value)
|
64
|
-
assert_exists
|
65
|
-
Option.new(self, attribute, value)
|
66
|
-
end
|
59
|
+
|
67
60
|
end
|
68
61
|
end
|