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,63 +1,76 @@
|
|
|
1
|
-
module Celerity
|
|
2
|
-
|
|
3
|
-
class Image < Element
|
|
4
|
-
include ClickableElement
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
ATTRIBUTES = BASE_ATTRIBUTES | [:src, :alt, :longdesc, :name, :height, :width, :usemap, :ismap, :align, :border, :hspace, :vspace]
|
|
9
|
-
DEFAULT_HOW = :src
|
|
10
|
-
|
|
11
|
-
#
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
end
|
|
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
|
-
|
|
1
|
+
module Celerity
|
|
2
|
+
|
|
3
|
+
class Image < Element
|
|
4
|
+
include ClickableElement
|
|
5
|
+
|
|
6
|
+
TAGS = [ Identifier.new('img') ]
|
|
7
|
+
|
|
8
|
+
ATTRIBUTES = BASE_ATTRIBUTES | [:src, :alt, :longdesc, :name, :height, :width, :usemap, :ismap, :align, :border, :hspace, :vspace]
|
|
9
|
+
DEFAULT_HOW = :src
|
|
10
|
+
|
|
11
|
+
#
|
|
12
|
+
# returns the file created date of the image
|
|
13
|
+
#
|
|
14
|
+
|
|
15
|
+
def file_created_date
|
|
16
|
+
assert_exists
|
|
17
|
+
web_response = @object.getWebResponse(true)
|
|
18
|
+
Time.parse(web_response.getResponseHeaderValue("Last-Modified").to_s)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
#
|
|
22
|
+
# returns the filesize of the image
|
|
23
|
+
#
|
|
24
|
+
|
|
25
|
+
def file_size
|
|
26
|
+
assert_exists
|
|
27
|
+
web_response = @object.getWebResponse(true)
|
|
28
|
+
web_response.getResponseBody.length
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
#
|
|
32
|
+
# returns the width in pixels of the image, as a string
|
|
33
|
+
#
|
|
34
|
+
|
|
35
|
+
def width
|
|
36
|
+
assert_exists
|
|
37
|
+
@object.getWidth
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
#
|
|
41
|
+
# returns the height in pixels of the image, as a string
|
|
42
|
+
#
|
|
43
|
+
|
|
44
|
+
def height
|
|
45
|
+
assert_exists
|
|
46
|
+
@object.getHeight
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
#
|
|
50
|
+
# returns true if the image is loaded
|
|
51
|
+
#
|
|
52
|
+
|
|
53
|
+
def loaded?
|
|
54
|
+
assert_exists
|
|
55
|
+
begin
|
|
56
|
+
@object.getImageReader
|
|
57
|
+
true
|
|
58
|
+
rescue
|
|
59
|
+
false
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
#
|
|
64
|
+
# Saves the image to the given file
|
|
65
|
+
#
|
|
66
|
+
|
|
67
|
+
def save(filename)
|
|
68
|
+
assert_exists
|
|
69
|
+
image_reader = @object.getImageReader
|
|
70
|
+
file = java.io.File.new(filename)
|
|
71
|
+
buffered_image = image_reader.read(0);
|
|
72
|
+
javax.imageio.ImageIO.write(buffered_image, image_reader.getFormatName(), file);
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
end # Image
|
|
76
|
+
end # Celerity
|
|
@@ -1,18 +1,30 @@
|
|
|
1
|
-
module Celerity
|
|
2
|
-
class Link < Element
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
module Celerity
|
|
2
|
+
class Link < Element
|
|
3
|
+
include ClickableElement
|
|
4
|
+
|
|
5
|
+
TAGS = [ Identifier.new('a') ]
|
|
6
|
+
ATTRIBUTES = BASE_ATTRIBUTES | [:charset, :type, :name, :href, :hreflang,
|
|
7
|
+
:target, :rel, :rev, :accesskey, :shape,
|
|
8
|
+
:coords, :tabindex, :onfocus, :onblur]
|
|
9
|
+
DEFAULT_HOW = :href
|
|
10
|
+
|
|
11
|
+
#
|
|
12
|
+
# Returns the absolute URL for this link (Celerity-specific)
|
|
13
|
+
#
|
|
14
|
+
# (Watir/IE does this for href(), but we don't want that.)
|
|
15
|
+
#
|
|
16
|
+
|
|
17
|
+
def absolute_url
|
|
18
|
+
assert_exists
|
|
19
|
+
href = @object.getAttributeValue('href')
|
|
20
|
+
|
|
21
|
+
unless href.empty? || URI.parse(href).absolute?
|
|
22
|
+
href = URI.join(browser.url, href).to_s
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
href
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
end # Link
|
|
30
|
+
end # Celerity
|
|
@@ -1,76 +1,106 @@
|
|
|
1
|
-
module Celerity
|
|
2
|
-
|
|
3
|
-
#
|
|
4
|
-
#
|
|
5
|
-
#
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
include
|
|
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
|
-
class
|
|
67
|
-
TAGS = [ Identifier.new('
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
end
|
|
1
|
+
module Celerity
|
|
2
|
+
|
|
3
|
+
#
|
|
4
|
+
# Superclass for for Span, Pre, Div, H1, ...
|
|
5
|
+
#
|
|
6
|
+
|
|
7
|
+
class NonControlElement < Element
|
|
8
|
+
include Exception
|
|
9
|
+
include ClickableElement
|
|
10
|
+
|
|
11
|
+
ATTRIBUTES = BASE_ATTRIBUTES
|
|
12
|
+
DEFAULT_HOW = :id
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
#
|
|
16
|
+
#--
|
|
17
|
+
# classes ordered alphabetically
|
|
18
|
+
#++
|
|
19
|
+
#
|
|
20
|
+
|
|
21
|
+
class Area < NonControlElement
|
|
22
|
+
ATTRIBUTES = ATTRIBUTES | [:shape, :coords, :href, :nohref, :alt, :tabindex, :accesskey, :onfocus, :onblur]
|
|
23
|
+
TAGS = [ Identifier.new('area') ]
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
class Dd < NonControlElement
|
|
27
|
+
TAGS = [ Identifier.new('dd')]
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
class Div < NonControlElement
|
|
31
|
+
TAGS = [ Identifier.new('div')]
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
class Dl < NonControlElement
|
|
35
|
+
TAGS = [ Identifier.new('dl')]
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
class Dt < NonControlElement
|
|
39
|
+
TAGS = [ Identifier.new('dt')]
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
class Em < NonControlElement
|
|
43
|
+
TAGS = [ Identifier.new('em')]
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
class H1 < NonControlElement
|
|
47
|
+
TAGS = [ Identifier.new('h1') ]
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
class H2 < NonControlElement
|
|
51
|
+
TAGS = [ Identifier.new('h2') ]
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
class H3 < NonControlElement
|
|
55
|
+
TAGS = [ Identifier.new('h3') ]
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
class H4 < NonControlElement
|
|
59
|
+
TAGS = [ Identifier.new('h4') ]
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
class H5 < NonControlElement
|
|
63
|
+
TAGS = [ Identifier.new('h5') ]
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
class H6 < NonControlElement
|
|
67
|
+
TAGS = [ Identifier.new('h6') ]
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
class Li < NonControlElement
|
|
71
|
+
TAGS = [ Identifier.new('li') ]
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
class Map < NonControlElement
|
|
75
|
+
TAGS = [ Identifier.new('map') ]
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
class Ol < NonControlElement
|
|
79
|
+
TAGS = [ Identifier.new('ol') ]
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
class P < NonControlElement
|
|
83
|
+
TAGS = [ Identifier.new('p') ]
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
class Pre < NonControlElement
|
|
87
|
+
TAGS = [ Identifier.new('pre')]
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
class Span < NonControlElement
|
|
91
|
+
TAGS = [ Identifier.new('span') ]
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
class Strong < NonControlElement
|
|
95
|
+
TAGS = [ Identifier.new('strong') ]
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# class Title < NonControlElement
|
|
99
|
+
# TAGS = [ Identifier.new('title') ]
|
|
100
|
+
# end
|
|
101
|
+
|
|
102
|
+
class Ul < NonControlElement
|
|
103
|
+
TAGS = [ Identifier.new('ul') ]
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
end
|
|
@@ -1,18 +1,32 @@
|
|
|
1
1
|
module Celerity
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
#
|
|
4
|
+
# Represents an option in a select list.
|
|
5
|
+
#
|
|
6
|
+
|
|
3
7
|
class Option < Element
|
|
4
8
|
include ClickableElement
|
|
5
9
|
include DisabledElement
|
|
6
|
-
|
|
10
|
+
|
|
7
11
|
TAGS = [ Identifier.new('option')]
|
|
8
12
|
ATTRIBUTES = BASE_ATTRIBUTES | [:selected, :disabled, :label, :value]
|
|
9
13
|
DEFAULT_HOW = :text
|
|
10
14
|
|
|
11
15
|
alias_method :select, :click
|
|
12
16
|
|
|
17
|
+
#
|
|
18
|
+
# Is this option selected?
|
|
19
|
+
#
|
|
20
|
+
|
|
13
21
|
def selected?
|
|
14
22
|
assert_exists
|
|
15
23
|
@object.isSelected
|
|
16
24
|
end
|
|
25
|
+
|
|
26
|
+
def label
|
|
27
|
+
# overrides Container#label
|
|
28
|
+
assert_exists
|
|
29
|
+
@object.getAttribute("label")
|
|
30
|
+
end
|
|
17
31
|
end
|
|
18
32
|
end
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
module Celerity
|
|
2
|
+
|
|
3
|
+
#
|
|
2
4
|
# Common superclass for radios and check boxes.
|
|
5
|
+
#
|
|
6
|
+
|
|
3
7
|
class RadioCheckCommon < InputElement
|
|
4
8
|
DEFAULT_HOW = :name
|
|
5
|
-
|
|
6
|
-
#
|
|
7
|
-
#
|
|
9
|
+
|
|
10
|
+
#
|
|
11
|
+
# Can optionally take a value parameter as a third arg, so we override initialize
|
|
12
|
+
#
|
|
13
|
+
|
|
8
14
|
def initialize(container, type, *args)
|
|
9
15
|
@type = type
|
|
10
16
|
case args.size
|
|
@@ -17,33 +23,51 @@ module Celerity
|
|
|
17
23
|
end
|
|
18
24
|
end
|
|
19
25
|
|
|
26
|
+
#
|
|
20
27
|
# returns true if the element is checked
|
|
28
|
+
# @return [true, false]
|
|
29
|
+
#
|
|
30
|
+
|
|
21
31
|
def set?
|
|
22
32
|
assert_exists
|
|
23
33
|
@object.isChecked
|
|
24
34
|
end
|
|
25
35
|
alias_method :checked?, :set?
|
|
36
|
+
|
|
37
|
+
#
|
|
38
|
+
# Unset this element.
|
|
39
|
+
#
|
|
26
40
|
|
|
27
41
|
def clear
|
|
28
42
|
set(false)
|
|
29
43
|
end
|
|
30
44
|
end
|
|
45
|
+
|
|
46
|
+
#
|
|
47
|
+
# This class is the representation of a radio button.
|
|
48
|
+
#
|
|
31
49
|
|
|
32
|
-
# This class is the celerity representation of a radio button.
|
|
33
50
|
class Radio < RadioCheckCommon
|
|
34
|
-
TAGS = [Identifier.new('input', :type => %w
|
|
35
|
-
|
|
51
|
+
TAGS = [Identifier.new('input', :type => %w[radio])]
|
|
52
|
+
|
|
53
|
+
#
|
|
54
|
+
# @api private
|
|
55
|
+
#
|
|
56
|
+
|
|
36
57
|
def initialize(container, *args)
|
|
37
|
-
super(container, [
|
|
58
|
+
super(container, %w[radio], *args)
|
|
38
59
|
end
|
|
39
60
|
|
|
40
|
-
# Sets the radio button.
|
|
41
61
|
#
|
|
42
|
-
#
|
|
43
|
-
#
|
|
44
|
-
# radio.set?
|
|
62
|
+
# Set the radio button to the given value.
|
|
63
|
+
#
|
|
64
|
+
# radio.set? #=> false
|
|
65
|
+
# radio.set
|
|
66
|
+
# radio.set? #=> true
|
|
45
67
|
# radio.set(false)
|
|
46
|
-
# radio.set?
|
|
68
|
+
# radio.set? #=> false
|
|
69
|
+
#
|
|
70
|
+
|
|
47
71
|
def set(value = true)
|
|
48
72
|
assert_exists
|
|
49
73
|
assert_enabled
|
|
@@ -52,24 +76,35 @@ module Celerity
|
|
|
52
76
|
|
|
53
77
|
end
|
|
54
78
|
|
|
55
|
-
#
|
|
79
|
+
#
|
|
80
|
+
# This class is the representation of a check box.
|
|
81
|
+
#
|
|
82
|
+
|
|
56
83
|
class CheckBox < RadioCheckCommon
|
|
57
|
-
TAGS = [Identifier.new('input', :type => %w
|
|
84
|
+
TAGS = [Identifier.new('input', :type => %w[checkbox])]
|
|
58
85
|
|
|
86
|
+
#
|
|
87
|
+
# @api private
|
|
88
|
+
#
|
|
89
|
+
|
|
59
90
|
def initialize(container, *args)
|
|
60
|
-
super(container, [
|
|
91
|
+
super(container, %w[checkbox], *args)
|
|
61
92
|
end
|
|
62
93
|
|
|
63
|
-
# Sets the checkbox button.
|
|
64
94
|
#
|
|
65
|
-
#
|
|
66
|
-
#
|
|
67
|
-
# checkbox.set?
|
|
95
|
+
# Set the checkbox to the given value.
|
|
96
|
+
#
|
|
97
|
+
# checkbox.set? #=> false
|
|
98
|
+
# checkbox.set
|
|
99
|
+
# checkbox.set? #=> true
|
|
68
100
|
# checkbox.set(false)
|
|
69
|
-
# checkbox.set?
|
|
101
|
+
# checkbox.set? #=> false
|
|
102
|
+
#
|
|
103
|
+
|
|
70
104
|
def set(value = true)
|
|
71
105
|
assert_exists
|
|
72
106
|
assert_enabled
|
|
107
|
+
|
|
73
108
|
if (value && !set?) || (!value && set?)
|
|
74
109
|
Log.debug(@object.inspect)
|
|
75
110
|
@container.update_page(@object.click)
|