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.
Files changed (158) hide show
  1. data/History.txt +33 -0
  2. data/README.txt +19 -9
  3. data/Rakefile +9 -3
  4. data/lib/celerity.rb +39 -39
  5. data/lib/celerity/browser.rb +538 -153
  6. data/lib/celerity/clickable_element.rb +48 -7
  7. data/lib/celerity/collections.rb +155 -131
  8. data/lib/celerity/container.rb +766 -385
  9. data/lib/celerity/default_viewer.rb +10 -0
  10. data/lib/celerity/disabled_element.rb +19 -2
  11. data/lib/celerity/element.rb +152 -83
  12. data/lib/celerity/element_collection.rb +106 -0
  13. data/lib/celerity/element_locator.rb +89 -66
  14. data/lib/celerity/elements/button.rb +23 -13
  15. data/lib/celerity/elements/file_field.rb +17 -5
  16. data/lib/celerity/elements/form.rb +21 -16
  17. data/lib/celerity/elements/frame.rb +75 -53
  18. data/lib/celerity/elements/image.rb +76 -63
  19. data/lib/celerity/elements/label.rb +4 -2
  20. data/lib/celerity/elements/link.rb +30 -18
  21. data/lib/celerity/elements/meta.rb +6 -0
  22. data/lib/celerity/{non_control_elements.rb → elements/non_control_elements.rb} +106 -76
  23. data/lib/celerity/elements/option.rb +16 -2
  24. data/lib/celerity/elements/radio_check.rb +55 -20
  25. data/lib/celerity/elements/select_list.rb +65 -29
  26. data/lib/celerity/elements/table.rb +141 -94
  27. data/lib/celerity/elements/table_cell.rb +13 -6
  28. data/lib/celerity/elements/{table_body.rb → table_elements.rb} +20 -8
  29. data/lib/celerity/elements/table_row.rb +23 -7
  30. data/lib/celerity/elements/text_field.rb +89 -33
  31. data/lib/celerity/exception.rb +77 -41
  32. data/lib/celerity/extra/method_generator.rb +42 -24
  33. data/lib/celerity/htmlunit.rb +49 -0
  34. data/lib/celerity/htmlunit/commons-collections-3.2.1.jar +0 -0
  35. data/lib/celerity/htmlunit/htmlunit-2.5-SNAPSHOT.jar +0 -0
  36. data/lib/celerity/htmlunit/htmlunit-core-js-2.5-SNAPSHOT.jar +0 -0
  37. data/lib/celerity/htmlunit/nekohtml-1.9.12-20090308.130127-11.jar +0 -0
  38. data/lib/celerity/htmlunit/serializer-2.7.1.jar +0 -0
  39. data/lib/celerity/htmlunit/xalan-2.7.1.jar +0 -0
  40. data/lib/celerity/htmlunit/xml-apis-1.3.04.jar +0 -0
  41. data/lib/celerity/identifier.rb +3 -2
  42. data/lib/celerity/input_element.rb +5 -5
  43. data/lib/celerity/listener.rb +135 -0
  44. data/lib/celerity/resources/no_viewer.png +0 -0
  45. data/lib/celerity/util.rb +88 -0
  46. data/lib/celerity/version.rb +4 -3
  47. data/lib/celerity/watir_compatibility.rb +35 -25
  48. data/tasks/jar.rake +57 -0
  49. metadata +35 -142
  50. data.tar.gz.sig +0 -0
  51. data/Manifest.txt +0 -150
  52. data/lib/celerity/element_collections.rb +0 -54
  53. data/lib/celerity/element_map.rb +0 -51
  54. data/lib/celerity/elements/table_footer.rb +0 -30
  55. data/lib/celerity/elements/table_header.rb +0 -30
  56. data/lib/celerity/htmlunit/commons-collections-3.2.jar +0 -0
  57. data/lib/celerity/htmlunit/download.sh +0 -23
  58. data/lib/celerity/htmlunit/htmlunit-2.2.jar +0 -0
  59. data/lib/celerity/htmlunit/htmlunit-core-js-2.2.jar +0 -0
  60. data/lib/celerity/htmlunit/nekohtml-1.9.8.jar +0 -0
  61. data/lib/celerity/htmlunit/xalan-2.7.0.jar +0 -0
  62. data/lib/celerity/htmlunit/xml-apis-1.0.b2.jar +0 -0
  63. data/spec/area_spec.rb +0 -97
  64. data/spec/areas_spec.rb +0 -40
  65. data/spec/browser_spec.rb +0 -266
  66. data/spec/button_spec.rb +0 -227
  67. data/spec/buttons_spec.rb +0 -39
  68. data/spec/checkbox_spec.rb +0 -302
  69. data/spec/checkboxes_spec.rb +0 -38
  70. data/spec/div_spec.rb +0 -207
  71. data/spec/divs_spec.rb +0 -39
  72. data/spec/element_spec.rb +0 -79
  73. data/spec/filefield_spec.rb +0 -123
  74. data/spec/filefields_spec.rb +0 -40
  75. data/spec/form_spec.rb +0 -59
  76. data/spec/forms_spec.rb +0 -41
  77. data/spec/frame_spec.rb +0 -121
  78. data/spec/frames_spec.rb +0 -71
  79. data/spec/hidden_spec.rb +0 -127
  80. data/spec/hiddens_spec.rb +0 -39
  81. data/spec/hn_spec.rb +0 -104
  82. data/spec/hns_spec.rb +0 -45
  83. data/spec/html/2000_spans.html +0 -2009
  84. data/spec/html/bug_duplicate_attributes.html +0 -14
  85. data/spec/html/bug_javascript_001.html +0 -11
  86. data/spec/html/form_js_bug.html +0 -11
  87. data/spec/html/forms_with_input_elements.html +0 -114
  88. data/spec/html/frame_1.html +0 -17
  89. data/spec/html/frame_2.html +0 -16
  90. data/spec/html/frames.html +0 -11
  91. data/spec/html/iframes.html +0 -12
  92. data/spec/html/images.html +0 -27
  93. data/spec/html/images/1.gif +0 -0
  94. data/spec/html/images/2.gif +0 -0
  95. data/spec/html/images/3.gif +0 -0
  96. data/spec/html/images/button.jpg +0 -0
  97. data/spec/html/images/circle.jpg +0 -0
  98. data/spec/html/images/map.gif +0 -0
  99. data/spec/html/images/map2.gif +0 -0
  100. data/spec/html/images/minus.gif +0 -0
  101. data/spec/html/images/originaltriangle.jpg +0 -0
  102. data/spec/html/images/plus.gif +0 -0
  103. data/spec/html/images/square.jpg +0 -0
  104. data/spec/html/images/triangle.jpg +0 -0
  105. data/spec/html/invalid_js.html +0 -11
  106. data/spec/html/latin1_text.html +0 -17
  107. data/spec/html/non_control_elements.html +0 -115
  108. data/spec/html/simple_ajax.html +0 -22
  109. data/spec/html/tables.html +0 -119
  110. data/spec/html/utf8_text.html +0 -15
  111. data/spec/htmlunit_spec.rb +0 -26
  112. data/spec/image_spec.rb +0 -220
  113. data/spec/images_spec.rb +0 -39
  114. data/spec/label_spec.rb +0 -79
  115. data/spec/labels_spec.rb +0 -40
  116. data/spec/li_spec.rb +0 -139
  117. data/spec/link_spec.rb +0 -189
  118. data/spec/links_spec.rb +0 -43
  119. data/spec/lis_spec.rb +0 -40
  120. data/spec/map_spec.rb +0 -102
  121. data/spec/maps_spec.rb +0 -40
  122. data/spec/meta_spec.rb +0 -8
  123. data/spec/ol_spec.rb +0 -87
  124. data/spec/ols_spec.rb +0 -40
  125. data/spec/option_spec.rb +0 -154
  126. data/spec/p_spec.rb +0 -171
  127. data/spec/pre_spec.rb +0 -135
  128. data/spec/pres_spec.rb +0 -40
  129. data/spec/ps_spec.rb +0 -40
  130. data/spec/radio_spec.rb +0 -299
  131. data/spec/radios_spec.rb +0 -42
  132. data/spec/select_list_spec.rb +0 -299
  133. data/spec/select_lists_spec.rb +0 -47
  134. data/spec/span_spec.rb +0 -184
  135. data/spec/spans_spec.rb +0 -64
  136. data/spec/spec.opts +0 -1
  137. data/spec/spec_helper.rb +0 -55
  138. data/spec/table_bodies_spec.rb +0 -57
  139. data/spec/table_body_spec.rb +0 -111
  140. data/spec/table_cell_spec.rb +0 -74
  141. data/spec/table_cells_spec.rb +0 -59
  142. data/spec/table_footer_spec.rb +0 -101
  143. data/spec/table_footers_spec.rb +0 -55
  144. data/spec/table_header_spec.rb +0 -101
  145. data/spec/table_headers_spec.rb +0 -55
  146. data/spec/table_row_spec.rb +0 -104
  147. data/spec/table_rows_spec.rb +0 -58
  148. data/spec/table_spec.rb +0 -160
  149. data/spec/tables_spec.rb +0 -42
  150. data/spec/text_field_spec.rb +0 -323
  151. data/spec/text_fields_spec.rb +0 -44
  152. data/spec/ul_spec.rb +0 -88
  153. data/spec/uls_spec.rb +0 -40
  154. data/spec/watir_compatibility_spec.rb +0 -260
  155. data/support/spec_server.rb +0 -73
  156. data/tasks/rspec.rake +0 -30
  157. data/tasks/specserver.rake +0 -21
  158. metadata.gz.sig +0 -0
data/spec/pre_spec.rb DELETED
@@ -1,135 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper.rb'
2
-
3
- describe "Pre" do
4
-
5
- before :all do
6
- @browser = Browser.new
7
- end
8
-
9
- before :each do
10
- @browser.goto(TEST_HOST + "/non_control_elements.html")
11
- end
12
-
13
- # Exists method
14
- describe "#exist?" do
15
- it "should return true if the 'p' exists" do
16
- @browser.pre(:id, "rspec").should exist
17
- @browser.pre(:id, /rspec/).should exist
18
- @browser.pre(:text, '@browser.pre(:id, "rspec").should exist').should exist
19
- @browser.pre(:text, /@browser\.pre/).should exist
20
- @browser.pre(:class, "ruby").should exist
21
- @browser.pre(:class, /ruby/).should exist
22
- @browser.pre(:index, 1).should exist
23
- @browser.pre(:xpath, "//pre[@id='rspec']").should exist
24
- end
25
-
26
- it "should return true if the element exists (default how = :id)" do
27
- @browser.pre("rspec").should exist
28
- end
29
-
30
- it "should return false if the 'p' doesn't exist" do
31
- @browser.pre(:id, "no_such_id").should_not exist
32
- @browser.pre(:id, /no_such_id/).should_not exist
33
- @browser.pre(:text, "no_such_text").should_not exist
34
- @browser.pre(:text, /no_such_text/).should_not exist
35
- @browser.pre(:class, "no_such_class").should_not exist
36
- @browser.pre(:class, /no_such_class/).should_not exist
37
- @browser.pre(:index, 1337).should_not exist
38
- @browser.pre(:xpath, "//pre[@id='no_such_id']").should_not exist
39
- end
40
-
41
- it "should raise ArgumentError when 'what' argument is invalid" do
42
- lambda { @browser.pre(:id, 3.14).exists? }.should raise_error(ArgumentError)
43
- end
44
-
45
- it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
46
- lambda { @browser.pre(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
47
- end
48
- end
49
-
50
- # Attribute methods
51
- describe "#class_name" do
52
- it "should return the class attribute" do
53
- @browser.pre(:id, 'rspec').class_name.should == 'ruby'
54
- end
55
-
56
- it "should return an empty string if the element exists and the attribute doesn't" do
57
- @browser.pre(:index, 1).class_name.should == ''
58
- end
59
-
60
- it "should raise UnknownObjectException if the p doesn't exist" do
61
- lambda { @browser.pre(:id, 'no_such_id').class_name }.should raise_error(UnknownObjectException)
62
- end
63
- end
64
-
65
- describe "#id" do
66
- it "should return the id attribute" do
67
- @browser.pre(:class, 'ruby').id.should == "rspec"
68
- end
69
-
70
- it "should return an empty string if the element exists and the attribute doesn't" do
71
- @browser.pre(:index, 1).id.should == ''
72
- end
73
-
74
- it "should raise UnknownObjectException if the p doesn't exist" do
75
- lambda { @browser.pre(:id, "no_such_id").id }.should raise_error(UnknownObjectException)
76
- lambda { @browser.pre(:index, 1337).id }.should raise_error(UnknownObjectException)
77
- end
78
- end
79
-
80
- describe "#title" do
81
- it "should return the title attribute" do
82
- @browser.pre(:class, 'brainfuck').title.should == 'The brainfuck language is an esoteric programming language noted for its extreme minimalism'
83
- end
84
-
85
- it "should return an empty string if the element exists and the attribute doesn't" do
86
- @browser.pre(:index, 1).title.should == ''
87
- end
88
-
89
- it "should raise UnknownObjectException if the p doesn't exist" do
90
- lambda { @browser.pre(:id, 'no_such_id').title }.should raise_error( UnknownObjectException)
91
- lambda { @browser.pre(:xpath, "//pre[@id='no_such_id']").title }.should raise_error( UnknownObjectException)
92
- end
93
- end
94
-
95
- describe "#text" do
96
- it "should return the text of the p" do
97
- @browser.pre(:class, 'haskell').text.should == 'main = putStrLn "Hello World"'
98
- end
99
-
100
- it "should return an empty string if the element doesn't contain any text" do
101
- @browser.pre(:index, 1).text.should == ''
102
- end
103
-
104
- it "should raise UnknownObjectException if the p doesn't exist" do
105
- lambda { @browser.pre(:id, 'no_such_id').text }.should raise_error( UnknownObjectException)
106
- lambda { @browser.pre(:xpath , "//pre[@id='no_such_id']").text }.should raise_error( UnknownObjectException)
107
- end
108
- end
109
-
110
- describe "#respond_to?" do
111
- it "should return true for all attribute methods" do
112
- @browser.image(:index, 1).should respond_to(:class_name)
113
- @browser.image(:index, 1).should respond_to(:id)
114
- @browser.image(:index, 1).should respond_to(:title)
115
- @browser.image(:index, 1).should respond_to(:text)
116
- end
117
- end
118
-
119
-
120
- # Other
121
- describe "#to_s" do
122
- it "should return a human readable representation of the element" do
123
- @browser.pre(:index, 1).to_s.should == "tag: pre"
124
- end
125
-
126
- it "should raise UnknownObjectException if the p doesn't exist" do
127
- lambda { @browser.pre(:xpath, "//pre[@id='no_such_id']").to_s }.should raise_error( UnknownObjectException)
128
- end
129
- end
130
-
131
- after :all do
132
- @browser.close
133
- end
134
-
135
- end
data/spec/pres_spec.rb DELETED
@@ -1,40 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper.rb'
2
-
3
- describe "Pres" do
4
-
5
- before :all do
6
- @browser = Browser.new
7
- end
8
-
9
- before :each do
10
- @browser.goto(TEST_HOST + "/non_control_elements.html")
11
- end
12
-
13
- describe "#length" do
14
- it "should return the number of pres" do
15
- @browser.pres.length.should == 7
16
- end
17
- end
18
-
19
- describe "#[]" do
20
- it "should return the pre at the given index" do
21
- @browser.pres[2].id.should == "rspec"
22
- end
23
- end
24
-
25
- describe "#each" do
26
- it "should iterate through pres correctly" do
27
- @browser.pres.each_with_index do |p, index|
28
- p.name.should == @browser.pre(:index, index+1).name
29
- p.id.should == @browser.pre(:index, index+1).id
30
- p.value.should == @browser.pre(:index, index+1).value
31
- end
32
- end
33
- end
34
-
35
- after :all do
36
- @browser.close
37
- end
38
-
39
- end
40
-
data/spec/ps_spec.rb DELETED
@@ -1,40 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper.rb'
2
-
3
- describe "Ps" do
4
-
5
- before :all do
6
- @browser = Browser.new
7
- end
8
-
9
- before :each do
10
- @browser.goto(TEST_HOST + "/non_control_elements.html")
11
- end
12
-
13
- describe "#length" do
14
- it "should return the number of ps" do
15
- @browser.ps.length.should == 5
16
- end
17
- end
18
-
19
- describe "#[]" do
20
- it "should return the p at the given index" do
21
- @browser.ps[1].id.should == "lead"
22
- end
23
- end
24
-
25
- describe "#each" do
26
- it "should iterate through ps correctly" do
27
- @browser.ps.each_with_index do |p, index|
28
- p.name.should == @browser.p(:index, index+1).name
29
- p.id.should == @browser.p(:index, index+1).id
30
- p.value.should == @browser.p(:index, index+1).value
31
- end
32
- end
33
- end
34
-
35
- after :all do
36
- @browser.close
37
- end
38
-
39
- end
40
-
data/spec/radio_spec.rb DELETED
@@ -1,299 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper.rb'
2
-
3
- describe "Radio" do
4
-
5
- before :all do
6
- @browser = Browser.new
7
- end
8
-
9
- before :each do
10
- @browser.goto(TEST_HOST + "/forms_with_input_elements.html")
11
- end
12
-
13
- # Exists method
14
- describe "#exists?" do
15
- it "should return true if the radio button exists" do
16
- @browser.radio(:id, "new_user_newsletter_yes").should exist
17
- @browser.radio(:id, /new_user_newsletter_yes/).should exist
18
- @browser.radio(:name, "new_user_newsletter").should exist
19
- @browser.radio(:name, /new_user_newsletter/).should exist
20
- @browser.radio(:value, "yes").should exist
21
- @browser.radio(:value, /yes/).should exist
22
- # TODO: figure out what :text means for a radio button
23
- # @browser.radio(:text, "yes").should exist
24
- # @browser.radio(:text, /yes/).should exist
25
- @browser.radio(:class, "huge").should exist
26
- @browser.radio(:class, /huge/).should exist
27
- @browser.radio(:index, 1).should exist
28
- @browser.radio(:xpath, "//input[@id='new_user_newsletter_yes']").should exist
29
- end
30
-
31
- it "should return true if the element exists (default how = :name)" do
32
- @browser.radio("new_user_newsletter").should exist
33
- end
34
-
35
- it "should return true if the radio button exists (search by name and value)" do
36
- @browser.radio(:name, "new_user_newsletter", 'yes').should exist
37
- @browser.radio(:xpath, "//input[@name='new_user_newsletter' and @value='yes']").set
38
- end
39
-
40
- it "should return false if the radio button does not exist" do
41
- @browser.radio(:id, "no_such_id").should_not exist
42
- @browser.radio(:id, /no_such_id/).should_not exist
43
- @browser.radio(:name, "no_such_name").should_not exist
44
- @browser.radio(:name, /no_such_name/).should_not exist
45
- @browser.radio(:value, "no_such_value").should_not exist
46
- @browser.radio(:value, /no_such_value/).should_not exist
47
- @browser.radio(:text, "no_such_text").should_not exist
48
- @browser.radio(:text, /no_such_text/).should_not exist
49
- @browser.radio(:class, "no_such_class").should_not exist
50
- @browser.radio(:class, /no_such_class/).should_not exist
51
- @browser.radio(:index, 1337).should_not exist
52
- @browser.radio(:xpath, "input[@id='no_such_id']").should_not exist
53
- end
54
-
55
- it "should return false if the radio button does not exist (search by name and value)" do
56
- @browser.radio(:name, "new_user_newsletter", 'no_such_value').should_not exist
57
- @browser.radio(:xpath, "//input[@name='new_user_newsletter' and @value='no_such_value']").should_not exist
58
- @browser.radio(:name, "no_such_name", 'yes').should_not exist
59
- @browser.radio(:xpath, "//input[@name='no_such_name' and @value='yes']").should_not exist
60
- end
61
-
62
- it "should return true for radios with a string value" do
63
- @browser.radio(:name, 'new_user_newsletter', 'yes').should exist
64
- @browser.radio(:name, 'new_user_newsletter', 'no').should exist
65
- end
66
-
67
- it "should raise ArgumentError when 'what' argument is invalid" do
68
- lambda { @browser.radio(:id, 3.14).exists? }.should raise_error(ArgumentError)
69
- end
70
-
71
- it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
72
- lambda { @browser.radio(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
73
- end
74
- end
75
-
76
-
77
- # Attribute methods
78
- describe "#class_name" do
79
- it "should return the class name if the radio exists and has an attribute" do
80
- @browser.radio(:id, "new_user_newsletter_yes").class_name.should == "huge"
81
- end
82
-
83
- it "should return an emptry string if the radio exists and the attribute doesn't" do
84
- @browser.radio(:id, "new_user_newsletter_no").class_name.should == ""
85
- end
86
-
87
- it "should raise UnknownObjectException if the radio doesn't exist" do
88
- lambda { @browser.radio(:id, "no_such_id").class_name }.should raise_error(UnknownObjectException)
89
- end
90
- end
91
-
92
- describe "#id" do
93
- it "should return the id attribute if the radio exists and has an attribute" do
94
- @browser.radio(:index, 1).id.should == "new_user_newsletter_yes"
95
- end
96
-
97
- it "should return an emptry string if the radio exists and the attribute doesn't" do
98
- @browser.radio(:index, 3).id.should == ""
99
- end
100
-
101
- it "should raise UnknownObjectException if the radio doesn't exist" do
102
- lambda { @browser.radio(:index, 1337).id }.should raise_error(UnknownObjectException)
103
- end
104
- end
105
-
106
- describe "#name" do
107
- it "should return the name attribute if the radio exists" do
108
- @browser.radio(:id, 'new_user_newsletter_yes').name.should == "new_user_newsletter"
109
- end
110
-
111
- it "should return an empty string if the radio exists and the attribute doesn't" do
112
- @browser.radio(:id, 'new_user_newsletter_absolutely').name.should == ""
113
- end
114
-
115
- it "should raise UnknownObjectException if the radio doesn't exist" do
116
- lambda { @browser.radio(:index, 1337).name }.should raise_error(UnknownObjectException)
117
- end
118
- end
119
-
120
- describe "#title" do
121
- it "should return the title attribute if the radio exists" do
122
- @browser.radio(:id, "new_user_newsletter_no").title.should == "Traitor!"
123
- end
124
-
125
- it "should return an emptry string if the radio exists and the attribute doesn't" do
126
- @browser.radio(:id, "new_user_newsletter_yes").title.should == ""
127
- end
128
-
129
- it "should raise UnknownObjectException if the radio doesn't exist" do
130
- lambda { @browser.radio(:index, 1337).title }.should raise_error(UnknownObjectException)
131
- end
132
- end
133
-
134
- describe "#type" do
135
- it "should return the type attribute if the radio exists" do
136
- @browser.radio(:index, 1).type.should == "radio"
137
- end
138
-
139
- it "should raise UnknownObjectException if the radio doesn't exist" do
140
- lambda { @browser.radio(:index, 1337).type }.should raise_error(UnknownObjectException)
141
- end
142
- end
143
-
144
- describe "#value" do
145
- it "should return the value attribute if the radio exists" do
146
- @browser.radio(:id, 'new_user_newsletter_yes').value.should == 'yes'
147
- end
148
-
149
- it "should raise UnknownObjectException if the radio doesn't exist" do
150
- lambda { @browser.radio(:index, 1337).value}.should raise_error(UnknownObjectException)
151
- end
152
- end
153
-
154
- describe "#respond_to?" do
155
- it "should return true for all attribute methods" do
156
- @browser.radio(:index, 1).should respond_to(:class_name)
157
- @browser.radio(:index, 1).should respond_to(:id)
158
- @browser.radio(:index, 1).should respond_to(:name)
159
- @browser.radio(:index, 1).should respond_to(:title)
160
- @browser.radio(:index, 1).should respond_to(:type)
161
- @browser.radio(:index, 1).should respond_to(:value)
162
- end
163
- end
164
-
165
-
166
-
167
- # Access methods
168
- describe "#enabled?" do
169
- it "should return true if the radio button is enabled" do
170
- @browser.radio(:id, "new_user_newsletter_yes").should be_enabled
171
- @browser.radio(:xpath, "//input[@id='new_user_newsletter_yes']").should be_enabled
172
- end
173
-
174
- it "should return false if the radio button is disabled" do
175
- @browser.radio(:id, "new_user_newsletter_nah").should_not be_enabled
176
- @browser.radio(:xpath,"//input[@id='new_user_newsletter_nah']").should_not be_enabled
177
- end
178
-
179
- it "should raise UnknownObjectException if the radio button doesn't exist" do
180
- lambda { @browser.radio(:id, "no_such_id").enabled? }.should raise_error(UnknownObjectException)
181
- lambda { @browser.radio(:xpath, "//input[@id='no_such_id']").enabled? }.should raise_error(UnknownObjectException)
182
- end
183
- end
184
-
185
- describe "#disabled?" do
186
- it "should return true if the radio is disabled" do
187
- @browser.radio(:id, 'new_user_newsletter_nah').should be_disabled
188
- end
189
-
190
- it "should return false if the radio is enabled" do
191
- @browser.radio(:id, 'new_user_newsletter_yes').should_not be_disabled
192
- end
193
-
194
- it "should raise UnknownObjectException if the radio doesn't exist" do
195
- lambda { @browser.radio(:index, 1337).disabled? }.should raise_error(UnknownObjectException)
196
- end
197
- end
198
-
199
-
200
- # Manipulation methods
201
- describe "#clear" do
202
- it "should clear the radio button if it is set" do
203
- @browser.radio(:id, "new_user_newsletter_yes").clear
204
- @browser.radio(:id, "new_user_newsletter_yes").should_not be_set
205
- end
206
-
207
- it "should clear the radio button when found by :xpath" do
208
- @browser.radio(:xpath, "//input[@id='new_user_newsletter_yes']").clear
209
- @browser.radio(:xpath, "//input[@id='new_user_newsletter_yes']").should_not be_set
210
- end
211
-
212
- it "should raise UnknownObjectException if the radio button doesn't exist" do
213
- lambda { @browser.radio(:name, "no_such_id").clear }.should raise_error(UnknownObjectException)
214
- lambda { @browser.radio(:xpath, "//input[@id='no_such_id']").clear }.should raise_error(UnknownObjectException)
215
- end
216
-
217
- it "should raise ObjectDisabledException if the radio is disabled" do
218
- @browser.radio(:id, "new_user_newsletter_nah").should_not be_set
219
- lambda { @browser.radio(:id, "new_user_newsletter_nah").clear }.should raise_error(ObjectDisabledException)
220
- lambda { @browser.radio(:xpath, "//input[@id='new_user_newsletter_nah']").clear }.should raise_error(ObjectDisabledException)
221
- end
222
- end
223
-
224
- describe "#set" do
225
- it "should set the radio button" do
226
- @browser.radio(:id, "new_user_newsletter_no").set
227
- @browser.radio(:id, "new_user_newsletter_no").should be_set
228
- end
229
-
230
- it "should set the radio button when found by :xpath" do
231
- @browser.radio(:xpath, "//input[@id='new_user_newsletter_no']").set
232
- @browser.radio(:xpath, "//input[@id='new_user_newsletter_no']").should be_set
233
- end
234
-
235
- it "should fire the onclick event" do
236
- @browser.div(:id, "wants_newsletter").text.should be_empty
237
- @browser.radio(:id, "new_user_newsletter_no").set
238
- @browser.div(:id, "wants_newsletter").text.should == @browser.radio(:id, "new_user_newsletter_no").title
239
- @browser.radio(:id, "new_user_newsletter_yes").set
240
- @browser.div(:id, "wants_newsletter").text.should be_empty
241
- end
242
-
243
- it "should raise UnknownObjectException if the radio button doesn't exist" do
244
- lambda { @browser.radio(:name, "no_such_name").set }.should raise_error(UnknownObjectException)
245
- lambda { @browser.radio(:xpath, "//input[@name='no_such_name']").set }.should raise_error(UnknownObjectException)
246
- end
247
-
248
- it "should raise ObjectDisabledException if the radio is disabled" do
249
- lambda { @browser.radio(:id, "new_user_newsletter_nah").set }.should raise_error(ObjectDisabledException)
250
- lambda { @browser.radio(:xpath, "//input[@id='new_user_newsletter_nah']").set }.should raise_error(ObjectDisabledException )
251
- end
252
- end
253
-
254
-
255
- # Other
256
- describe '#set?' do
257
- it "should return true if the radio button is set" do
258
- @browser.radio(:id, "new_user_newsletter_yes").should be_set
259
- end
260
-
261
- it "should return false if the radio button unset" do
262
- @browser.radio(:id, "new_user_newsletter_no").should_not be_set
263
- end
264
-
265
- it "should return the state for radios with string values" do
266
- @browser.radio(:name, "new_user_newsletter", 'no').should_not be_set
267
- @browser.radio(:name, "new_user_newsletter", 'no').set
268
- @browser.radio(:name, "new_user_newsletter", 'no').should be_set
269
- @browser.radio(:name, "new_user_newsletter", 'no').clear
270
- @browser.radio(:name, "new_user_newsletter", 'no').should_not be_set
271
- end
272
-
273
- it "should raise UnknownObjectException if the radio button doesn't exist" do
274
- lambda { @browser.radio(:id, "no_such_id").set? }.should raise_error(UnknownObjectException)
275
- lambda { @browser.radio(:xpath, "//input[@id='no_such_id']").set? }.should raise_error(UnknownObjectException)
276
- end
277
- end
278
-
279
- describe "#get_state" do
280
- it "should return true if the radio is set" do
281
- @browser.radio(:id, "new_user_newsletter_yes").get_state.should be_true
282
- end
283
-
284
- it "should return false if the radio is unset" do
285
- @browser.radio(:id, "new_user_newsletter_no").get_state.should be_false
286
- end
287
-
288
- it "should raise UnknownObjectException if the radio doesn't exist" do
289
- lambda { @browser.radio(:name, "no_such_name").get_state }.should raise_error(UnknownObjectException)
290
- lambda { @browser.radio(:xpath, "//input[@name='no_such_name']").get_state }.should raise_error(UnknownObjectException)
291
- end
292
- end
293
-
294
- after :all do
295
- @browser.close
296
- end
297
-
298
- end
299
-