celerity 0.0.4 → 0.0.6
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/History.txt +33 -0
- data/README.txt +19 -9
- data/Rakefile +9 -3
- data/lib/celerity.rb +39 -39
- data/lib/celerity/browser.rb +538 -153
- data/lib/celerity/clickable_element.rb +48 -7
- data/lib/celerity/collections.rb +155 -131
- data/lib/celerity/container.rb +766 -385
- data/lib/celerity/default_viewer.rb +10 -0
- data/lib/celerity/disabled_element.rb +19 -2
- data/lib/celerity/element.rb +152 -83
- data/lib/celerity/element_collection.rb +106 -0
- data/lib/celerity/element_locator.rb +89 -66
- data/lib/celerity/elements/button.rb +23 -13
- data/lib/celerity/elements/file_field.rb +17 -5
- data/lib/celerity/elements/form.rb +21 -16
- data/lib/celerity/elements/frame.rb +75 -53
- data/lib/celerity/elements/image.rb +76 -63
- data/lib/celerity/elements/label.rb +4 -2
- data/lib/celerity/elements/link.rb +30 -18
- data/lib/celerity/elements/meta.rb +6 -0
- data/lib/celerity/{non_control_elements.rb → elements/non_control_elements.rb} +106 -76
- data/lib/celerity/elements/option.rb +16 -2
- data/lib/celerity/elements/radio_check.rb +55 -20
- data/lib/celerity/elements/select_list.rb +65 -29
- data/lib/celerity/elements/table.rb +141 -94
- data/lib/celerity/elements/table_cell.rb +13 -6
- data/lib/celerity/elements/{table_body.rb → table_elements.rb} +20 -8
- data/lib/celerity/elements/table_row.rb +23 -7
- data/lib/celerity/elements/text_field.rb +89 -33
- data/lib/celerity/exception.rb +77 -41
- data/lib/celerity/extra/method_generator.rb +42 -24
- data/lib/celerity/htmlunit.rb +49 -0
- data/lib/celerity/htmlunit/commons-collections-3.2.1.jar +0 -0
- data/lib/celerity/htmlunit/htmlunit-2.5-SNAPSHOT.jar +0 -0
- data/lib/celerity/htmlunit/htmlunit-core-js-2.5-SNAPSHOT.jar +0 -0
- data/lib/celerity/htmlunit/nekohtml-1.9.12-20090308.130127-11.jar +0 -0
- data/lib/celerity/htmlunit/serializer-2.7.1.jar +0 -0
- data/lib/celerity/htmlunit/xalan-2.7.1.jar +0 -0
- data/lib/celerity/htmlunit/xml-apis-1.3.04.jar +0 -0
- data/lib/celerity/identifier.rb +3 -2
- data/lib/celerity/input_element.rb +5 -5
- data/lib/celerity/listener.rb +135 -0
- data/lib/celerity/resources/no_viewer.png +0 -0
- data/lib/celerity/util.rb +88 -0
- data/lib/celerity/version.rb +4 -3
- data/lib/celerity/watir_compatibility.rb +35 -25
- data/tasks/jar.rake +57 -0
- metadata +35 -142
- data.tar.gz.sig +0 -0
- data/Manifest.txt +0 -150
- data/lib/celerity/element_collections.rb +0 -54
- data/lib/celerity/element_map.rb +0 -51
- data/lib/celerity/elements/table_footer.rb +0 -30
- data/lib/celerity/elements/table_header.rb +0 -30
- data/lib/celerity/htmlunit/commons-collections-3.2.jar +0 -0
- data/lib/celerity/htmlunit/download.sh +0 -23
- data/lib/celerity/htmlunit/htmlunit-2.2.jar +0 -0
- data/lib/celerity/htmlunit/htmlunit-core-js-2.2.jar +0 -0
- data/lib/celerity/htmlunit/nekohtml-1.9.8.jar +0 -0
- data/lib/celerity/htmlunit/xalan-2.7.0.jar +0 -0
- data/lib/celerity/htmlunit/xml-apis-1.0.b2.jar +0 -0
- data/spec/area_spec.rb +0 -97
- data/spec/areas_spec.rb +0 -40
- data/spec/browser_spec.rb +0 -266
- data/spec/button_spec.rb +0 -227
- data/spec/buttons_spec.rb +0 -39
- data/spec/checkbox_spec.rb +0 -302
- data/spec/checkboxes_spec.rb +0 -38
- data/spec/div_spec.rb +0 -207
- data/spec/divs_spec.rb +0 -39
- data/spec/element_spec.rb +0 -79
- data/spec/filefield_spec.rb +0 -123
- data/spec/filefields_spec.rb +0 -40
- data/spec/form_spec.rb +0 -59
- data/spec/forms_spec.rb +0 -41
- data/spec/frame_spec.rb +0 -121
- data/spec/frames_spec.rb +0 -71
- data/spec/hidden_spec.rb +0 -127
- data/spec/hiddens_spec.rb +0 -39
- data/spec/hn_spec.rb +0 -104
- data/spec/hns_spec.rb +0 -45
- data/spec/html/2000_spans.html +0 -2009
- data/spec/html/bug_duplicate_attributes.html +0 -14
- data/spec/html/bug_javascript_001.html +0 -11
- data/spec/html/form_js_bug.html +0 -11
- data/spec/html/forms_with_input_elements.html +0 -114
- data/spec/html/frame_1.html +0 -17
- data/spec/html/frame_2.html +0 -16
- data/spec/html/frames.html +0 -11
- data/spec/html/iframes.html +0 -12
- data/spec/html/images.html +0 -27
- data/spec/html/images/1.gif +0 -0
- data/spec/html/images/2.gif +0 -0
- data/spec/html/images/3.gif +0 -0
- data/spec/html/images/button.jpg +0 -0
- data/spec/html/images/circle.jpg +0 -0
- data/spec/html/images/map.gif +0 -0
- data/spec/html/images/map2.gif +0 -0
- data/spec/html/images/minus.gif +0 -0
- data/spec/html/images/originaltriangle.jpg +0 -0
- data/spec/html/images/plus.gif +0 -0
- data/spec/html/images/square.jpg +0 -0
- data/spec/html/images/triangle.jpg +0 -0
- data/spec/html/invalid_js.html +0 -11
- data/spec/html/latin1_text.html +0 -17
- data/spec/html/non_control_elements.html +0 -115
- data/spec/html/simple_ajax.html +0 -22
- data/spec/html/tables.html +0 -119
- data/spec/html/utf8_text.html +0 -15
- data/spec/htmlunit_spec.rb +0 -26
- data/spec/image_spec.rb +0 -220
- data/spec/images_spec.rb +0 -39
- data/spec/label_spec.rb +0 -79
- data/spec/labels_spec.rb +0 -40
- data/spec/li_spec.rb +0 -139
- data/spec/link_spec.rb +0 -189
- data/spec/links_spec.rb +0 -43
- data/spec/lis_spec.rb +0 -40
- data/spec/map_spec.rb +0 -102
- data/spec/maps_spec.rb +0 -40
- data/spec/meta_spec.rb +0 -8
- data/spec/ol_spec.rb +0 -87
- data/spec/ols_spec.rb +0 -40
- data/spec/option_spec.rb +0 -154
- data/spec/p_spec.rb +0 -171
- data/spec/pre_spec.rb +0 -135
- data/spec/pres_spec.rb +0 -40
- data/spec/ps_spec.rb +0 -40
- data/spec/radio_spec.rb +0 -299
- data/spec/radios_spec.rb +0 -42
- data/spec/select_list_spec.rb +0 -299
- data/spec/select_lists_spec.rb +0 -47
- data/spec/span_spec.rb +0 -184
- data/spec/spans_spec.rb +0 -64
- data/spec/spec.opts +0 -1
- data/spec/spec_helper.rb +0 -55
- data/spec/table_bodies_spec.rb +0 -57
- data/spec/table_body_spec.rb +0 -111
- data/spec/table_cell_spec.rb +0 -74
- data/spec/table_cells_spec.rb +0 -59
- data/spec/table_footer_spec.rb +0 -101
- data/spec/table_footers_spec.rb +0 -55
- data/spec/table_header_spec.rb +0 -101
- data/spec/table_headers_spec.rb +0 -55
- data/spec/table_row_spec.rb +0 -104
- data/spec/table_rows_spec.rb +0 -58
- data/spec/table_spec.rb +0 -160
- data/spec/tables_spec.rb +0 -42
- data/spec/text_field_spec.rb +0 -323
- data/spec/text_fields_spec.rb +0 -44
- data/spec/ul_spec.rb +0 -88
- data/spec/uls_spec.rb +0 -40
- data/spec/watir_compatibility_spec.rb +0 -260
- data/support/spec_server.rb +0 -73
- data/tasks/rspec.rake +0 -30
- data/tasks/specserver.rake +0 -21
- metadata.gz.sig +0 -0
|
@@ -1,70 +1,106 @@
|
|
|
1
1
|
module Celerity
|
|
2
|
-
#
|
|
3
|
-
# Input: Select
|
|
4
|
-
#
|
|
5
|
-
# This class is the way in which select boxes are manipulated
|
|
6
|
-
# Normally a user would not need to create this object as it is returned by the Watir::Container#select_list method
|
|
7
2
|
class SelectList < InputElement
|
|
8
3
|
TAGS = [ Identifier.new('select') ]
|
|
9
4
|
DEFAULT_HOW = :name
|
|
10
|
-
|
|
11
|
-
#
|
|
12
|
-
|
|
5
|
+
|
|
6
|
+
#
|
|
7
|
+
# @return [Array<String>] An array of strings representing the text value of the select list's options.
|
|
8
|
+
#
|
|
9
|
+
|
|
10
|
+
def options
|
|
13
11
|
assert_exists
|
|
14
12
|
@object.getOptions.map { |e| e.asText }
|
|
15
13
|
end
|
|
16
|
-
|
|
17
|
-
#
|
|
18
|
-
|
|
14
|
+
|
|
15
|
+
#
|
|
16
|
+
# @return [Array<String>] An array of strings representing the text value of the currently selected options.
|
|
17
|
+
#
|
|
18
|
+
|
|
19
|
+
def selected_options
|
|
19
20
|
assert_exists
|
|
20
21
|
@object.getSelectedOptions.map { |e| e.asText }
|
|
21
22
|
end
|
|
22
|
-
|
|
23
|
+
|
|
24
|
+
#
|
|
23
25
|
# Clear all selected options
|
|
24
|
-
#
|
|
25
|
-
|
|
26
|
+
#
|
|
27
|
+
|
|
28
|
+
def clear
|
|
26
29
|
# assert_exists called by SelectList#type here
|
|
30
|
+
# TODO: should update page for each option changed?
|
|
27
31
|
@object.getSelectedOptions.each { |e| e.setSelected(false) } unless type() == 'select-one'
|
|
28
32
|
end
|
|
29
|
-
|
|
33
|
+
|
|
34
|
+
#
|
|
30
35
|
# Select the option(s) matching the given value.
|
|
31
|
-
# value can be a String or Regexp.
|
|
32
|
-
#
|
|
33
36
|
# If several options match the value given, all will be selected.
|
|
37
|
+
#
|
|
38
|
+
# @param [String, Regexp] value A value.
|
|
39
|
+
# @raise [Celerity::Exception::NoValueFoundException] if the value does not exist.
|
|
40
|
+
# @return [String, nil] The option selected. If multiple options match, returns the first match
|
|
41
|
+
#
|
|
42
|
+
#
|
|
43
|
+
|
|
34
44
|
def select(value)
|
|
35
45
|
assert_exists
|
|
36
|
-
raise NoValueFoundException, "unknown option with value #{value.inspect}" unless include?(value)
|
|
46
|
+
raise NoValueFoundException, "unknown option with value #{value.inspect} for select_list #{@conditions.inspect}" unless include?(value)
|
|
47
|
+
|
|
48
|
+
selected = nil
|
|
37
49
|
@object.getOptions.select { |e| matches?(e.asText, value) }.each do |option|
|
|
38
|
-
|
|
50
|
+
selected ||= option.asText
|
|
51
|
+
@container.update_page option.click
|
|
39
52
|
end
|
|
53
|
+
|
|
54
|
+
selected
|
|
40
55
|
end
|
|
41
56
|
alias_method :set, :select
|
|
42
|
-
|
|
57
|
+
|
|
58
|
+
#
|
|
43
59
|
# Returns true if the select list has one or more options matching the given value.
|
|
44
|
-
#
|
|
60
|
+
#
|
|
61
|
+
# @param [String, Regexp] value A value.
|
|
62
|
+
# @return [true, false]
|
|
63
|
+
#
|
|
64
|
+
|
|
45
65
|
def include?(value)
|
|
46
66
|
assert_exists
|
|
47
67
|
!!@object.getOptions.find { |e| matches?(e.asText, value) }
|
|
48
68
|
end
|
|
49
|
-
|
|
69
|
+
|
|
70
|
+
#
|
|
50
71
|
# Returns true if any of the selected options match the given value.
|
|
51
|
-
#
|
|
72
|
+
#
|
|
73
|
+
# @param [String, Regexp] value A value.
|
|
74
|
+
# @raise [Celerity::Exception::UnknownObjectException] if the value does not exist.
|
|
75
|
+
# @return [true, false]
|
|
76
|
+
#
|
|
77
|
+
|
|
52
78
|
def selected?(value)
|
|
53
79
|
assert_exists
|
|
54
|
-
raise UnknownObjectException, "unknown option with value #{value.inspect}" unless include?(value)
|
|
80
|
+
raise UnknownObjectException, "unknown option with value #{value.inspect} for select_list #{@conditions.inspect}" unless include?(value)
|
|
55
81
|
!!@object.getOptions.find { |e| matches?(e.asText, value) && e.isSelected }
|
|
56
82
|
end
|
|
57
83
|
|
|
58
|
-
#
|
|
59
|
-
#
|
|
84
|
+
#
|
|
85
|
+
# Returns 'select-multiple' if the select list has the 'multiple' attribute,
|
|
86
|
+
# defined, otherwise 'select-one'.
|
|
87
|
+
#
|
|
88
|
+
# @return [String]
|
|
60
89
|
# TODO: Move to watir_compatibility or delete it 2008-05-23 Alexander
|
|
90
|
+
#
|
|
91
|
+
|
|
61
92
|
def type
|
|
62
93
|
assert_exists
|
|
63
94
|
'select-' + (@object.isAttributeDefined('multiple') ? 'multiple' : 'one')
|
|
64
95
|
end
|
|
65
|
-
|
|
96
|
+
|
|
97
|
+
#
|
|
66
98
|
# Returns the value of the first selected option in the select list.
|
|
67
99
|
# Returns nil if no option is selected.
|
|
100
|
+
#
|
|
101
|
+
# @return [String, nil]
|
|
102
|
+
#
|
|
103
|
+
|
|
68
104
|
def value
|
|
69
105
|
assert_exists
|
|
70
106
|
if (optn = @object.getSelectedOptions.to_a.first)
|
|
@@ -72,5 +108,5 @@ module Celerity
|
|
|
72
108
|
end
|
|
73
109
|
end
|
|
74
110
|
|
|
75
|
-
end
|
|
76
|
-
end
|
|
111
|
+
end # SelectList
|
|
112
|
+
end # Celerity
|
|
@@ -1,94 +1,141 @@
|
|
|
1
|
-
module Celerity
|
|
2
|
-
|
|
3
|
-
class Table < Element
|
|
4
|
-
include
|
|
5
|
-
include
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
@
|
|
17
|
-
@
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
#
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
#
|
|
45
|
-
#
|
|
46
|
-
#
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
#
|
|
55
|
-
#
|
|
56
|
-
#
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
#
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
#
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
(
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
1
|
+
module Celerity
|
|
2
|
+
|
|
3
|
+
class Table < Element
|
|
4
|
+
include ClickableElement
|
|
5
|
+
include Enumerable
|
|
6
|
+
include Container
|
|
7
|
+
|
|
8
|
+
TAGS = [ Identifier.new('table') ]
|
|
9
|
+
ATTRIBUTES = BASE_ATTRIBUTES | [:summary, :width, :border, :frame, :rules,
|
|
10
|
+
:cellspacing, :cellpadding, :align, :bgcolor]
|
|
11
|
+
DEFAULT_HOW = :id
|
|
12
|
+
|
|
13
|
+
def locate
|
|
14
|
+
super
|
|
15
|
+
if @object # cant call assert_exists here, as an exists? method call will fail
|
|
16
|
+
@rows = @object.getRows
|
|
17
|
+
@cells = []
|
|
18
|
+
@rows.each do |row|
|
|
19
|
+
row.getCells.each do |c|
|
|
20
|
+
@cells << c
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
#
|
|
27
|
+
# @return [Celerity::TableRows]
|
|
28
|
+
#
|
|
29
|
+
|
|
30
|
+
def rows
|
|
31
|
+
assert_exists
|
|
32
|
+
TableRows.new(self, :object, @rows)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
#
|
|
36
|
+
# @return [Celerity::TableCells]
|
|
37
|
+
#
|
|
38
|
+
|
|
39
|
+
def cells
|
|
40
|
+
assert_exists
|
|
41
|
+
TableCells.new(self, :object, @cells)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
#
|
|
45
|
+
# Iterates through each row in the table.
|
|
46
|
+
# @yieldparam [Celerity::TableRow] row A row.
|
|
47
|
+
#
|
|
48
|
+
|
|
49
|
+
def each
|
|
50
|
+
assert_exists
|
|
51
|
+
@rows.each { |row| yield TableRow.new(self, :object, row) }
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
#
|
|
55
|
+
# Returns the TableRow at the given index (1-indexed).
|
|
56
|
+
#
|
|
57
|
+
# browser.table(:foo, 'bar')[1] # => #<TableRow...>
|
|
58
|
+
# browser.table(:foo, 'bar').child_row[1] # => #<TableRow...>
|
|
59
|
+
#
|
|
60
|
+
# @param [Fixnum] index The index of the wanted row, 1-indexed.
|
|
61
|
+
# @raise [Celerity::Exception::UnknownRowException]
|
|
62
|
+
# @return [Celerity::TableRow]
|
|
63
|
+
#
|
|
64
|
+
|
|
65
|
+
def child_row(index)
|
|
66
|
+
assert_exists
|
|
67
|
+
|
|
68
|
+
if (index - INDEX_OFFSET) >= @rows.length
|
|
69
|
+
raise UnknownRowException, "Unable to locate a row at index #{index}"
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
TableRow.new(self, :object, @rows[index - INDEX_OFFSET])
|
|
73
|
+
end
|
|
74
|
+
alias_method :[], :child_row
|
|
75
|
+
|
|
76
|
+
#
|
|
77
|
+
# Returns the TableCell at the given index (1-indexed).
|
|
78
|
+
#
|
|
79
|
+
# In a 10-column row, table.child_cell[11] will return the first cell on the second row.
|
|
80
|
+
#
|
|
81
|
+
# @param [Fixnum] index The index of the wanted cell, 1-indexed.
|
|
82
|
+
# @raise [Celerity::Exception::UnknownCellException]
|
|
83
|
+
# @return [Celerity::TableCell]
|
|
84
|
+
#
|
|
85
|
+
|
|
86
|
+
def child_cell(index)
|
|
87
|
+
assert_exists
|
|
88
|
+
|
|
89
|
+
if (index - INDEX_OFFSET) >= @cells.length
|
|
90
|
+
raise UnknownCellException, "Unable to locate a cell at index #{index}"
|
|
91
|
+
end
|
|
92
|
+
TableCell.new(self, :object, @cells[index - INDEX_OFFSET])
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
#
|
|
96
|
+
# The number of rows in the table
|
|
97
|
+
# @return [Fixnum]
|
|
98
|
+
#
|
|
99
|
+
|
|
100
|
+
def row_count
|
|
101
|
+
assert_exists
|
|
102
|
+
@object.getRowCount
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
#
|
|
106
|
+
# Returns the number of columns on the row at the given index. (1-indexed)
|
|
107
|
+
# Default is the number of columns on the first row
|
|
108
|
+
# @param [Fixnum] index An index, 1-indexed (optional).
|
|
109
|
+
# @return [Fixnum]
|
|
110
|
+
#
|
|
111
|
+
|
|
112
|
+
def column_count(index = INDEX_OFFSET)
|
|
113
|
+
assert_exists
|
|
114
|
+
@object.getRow(index - INDEX_OFFSET).getCells.length
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
#
|
|
118
|
+
# Returns the text of each cell in the the table as a two-dimensional array.
|
|
119
|
+
# @return [Array<Array<String>>]
|
|
120
|
+
#
|
|
121
|
+
|
|
122
|
+
def to_a
|
|
123
|
+
assert_exists
|
|
124
|
+
# @object.getRows.map do |table_row|
|
|
125
|
+
# table_row.getCells.map { |td| td.asText.strip }
|
|
126
|
+
# end
|
|
127
|
+
rows.map do |table_row|
|
|
128
|
+
table_row.map { |td| td.text }
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
def column_values(column_number)
|
|
133
|
+
(1..row_count).map { |index| self[index][column_number].text }
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
def row_values(row_number)
|
|
137
|
+
(1..column_count(row_number)).map { |index| self[row_number][index].text }
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
end # Table
|
|
141
|
+
end # Celerity
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
module Celerity
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
class TableCell < Element
|
|
4
4
|
include Celerity::Exception
|
|
5
|
+
include ClickableElement
|
|
5
6
|
include Container
|
|
6
7
|
|
|
7
8
|
TAGS = [ Identifier.new('td') ]
|
|
8
|
-
ATTRIBUTES = BASE_ATTRIBUTES | CELLHALIGN_ATTRIBUTES |
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
ATTRIBUTES = BASE_ATTRIBUTES | CELLHALIGN_ATTRIBUTES |
|
|
10
|
+
CELLVALIGN_ATTRIBUTES | [:abbr, :axis, :headers, :scope, :rowspan, :colspan]
|
|
11
|
+
|
|
11
12
|
DEFAULT_HOW = :id
|
|
12
|
-
|
|
13
|
-
alias_method :to_s, :text
|
|
13
|
+
|
|
14
|
+
alias_method :to_s, :text # why?
|
|
14
15
|
|
|
15
16
|
def colspan
|
|
16
17
|
assert_exists
|
|
@@ -19,4 +20,10 @@ module Celerity
|
|
|
19
20
|
end
|
|
20
21
|
|
|
21
22
|
end
|
|
23
|
+
|
|
24
|
+
#-- needs code review regarding attributes/correctness of this
|
|
25
|
+
class Th < TableCell
|
|
26
|
+
TAGS = [ Identifier.new('th')]
|
|
27
|
+
end
|
|
28
|
+
|
|
22
29
|
end
|
|
@@ -1,30 +1,42 @@
|
|
|
1
1
|
module Celerity
|
|
2
|
-
class
|
|
3
|
-
include Enumerable
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
class TableElement < Element
|
|
3
|
+
include Enumerable
|
|
4
|
+
include ClickableElement
|
|
5
|
+
|
|
6
6
|
ATTRIBUTES = BASE_ATTRIBUTES | CELLHALIGN_ATTRIBUTES | CELLVALIGN_ATTRIBUTES
|
|
7
7
|
DEFAULT_HOW = :id
|
|
8
8
|
|
|
9
9
|
def locate
|
|
10
10
|
super
|
|
11
|
-
@rows = @object.getRows if @object
|
|
11
|
+
@rows = @object.getRows if @object
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
def [](index)
|
|
15
15
|
assert_exists
|
|
16
|
-
TableRow.new(self, :object, @rows[index-
|
|
16
|
+
TableRow.new(self, :object, @rows[index - INDEX_OFFSET])
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
def length
|
|
20
20
|
assert_exists
|
|
21
21
|
@object.getRows.length
|
|
22
22
|
end
|
|
23
|
-
|
|
23
|
+
|
|
24
24
|
def each
|
|
25
25
|
assert_exists
|
|
26
26
|
@rows.each { |row| yield TableRow.new(self, :object, row) }
|
|
27
27
|
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
class TableBody < TableElement
|
|
31
|
+
TAGS = [ Identifier.new('tbody') ]
|
|
32
|
+
end
|
|
28
33
|
|
|
34
|
+
class TableFooter < TableElement
|
|
35
|
+
TAGS = [ Identifier.new('tfoot') ]
|
|
29
36
|
end
|
|
30
|
-
|
|
37
|
+
|
|
38
|
+
class TableHeader < TableElement
|
|
39
|
+
TAGS = [ Identifier.new('thead') ]
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
end
|