celerity 0.0.1 → 0.0.2
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 +10 -0
- data/README.txt +8 -11
- data/Rakefile +5 -3
- data/benchmark/bm_2000_spans.rb +48 -0
- data/benchmark/bm_digg.rb +26 -0
- data/benchmark/bm_google_images.rb +36 -0
- data/benchmark/bm_input_locator.rb +69 -0
- data/benchmark/loader.rb +9 -0
- data/lib/celerity.rb +3 -1
- data/lib/celerity/container.rb +23 -171
- data/lib/celerity/disabled_element.rb +1 -1
- data/lib/celerity/element.rb +78 -47
- data/lib/celerity/element_collections.rb +16 -32
- data/lib/celerity/element_locator.rb +135 -0
- data/lib/celerity/elements/button.rb +15 -0
- data/lib/celerity/elements/file_field.rb +1 -1
- data/lib/celerity/elements/form.rb +2 -1
- data/lib/celerity/elements/frame.rb +18 -21
- data/lib/celerity/elements/image.rb +2 -8
- data/lib/celerity/elements/label.rb +1 -3
- data/lib/celerity/elements/link.rb +1 -1
- data/lib/celerity/elements/option.rb +16 -0
- data/lib/celerity/elements/radio_check.rb +18 -7
- data/lib/celerity/elements/select_list.rb +1 -17
- data/lib/celerity/elements/table.rb +4 -4
- data/lib/celerity/elements/table_body.rb +6 -8
- data/lib/celerity/elements/table_cell.rb +3 -14
- data/lib/celerity/elements/table_row.rb +4 -10
- data/lib/celerity/elements/text_field.rb +16 -4
- data/lib/celerity/extra/method_generator.rb +144 -0
- data/lib/celerity/identifier.rb +10 -0
- data/lib/celerity/ie.rb +28 -13
- data/lib/celerity/input_element.rb +0 -4
- data/lib/celerity/non_control_elements.rb +12 -12
- data/lib/celerity/version.rb +1 -1
- data/spec/area_spec.rb +41 -41
- data/spec/areas_spec.rb +11 -11
- data/spec/button_spec.rb +73 -68
- data/spec/buttons_spec.rb +10 -10
- data/spec/checkbox_spec.rb +102 -96
- data/spec/checkboxes_spec.rb +10 -10
- data/spec/div_spec.rb +78 -73
- data/spec/divs_spec.rb +10 -10
- data/spec/element_spec.rb +20 -11
- data/spec/filefield_spec.rb +36 -41
- data/spec/filefields_spec.rb +10 -10
- data/spec/form_spec.rb +29 -29
- data/spec/forms_spec.rb +11 -11
- data/spec/frame_spec.rb +54 -49
- data/spec/hidden_spec.rb +43 -43
- data/spec/hiddens_spec.rb +10 -10
- data/spec/html/2000_spans.html +2009 -0
- data/spec/html/forms_with_input_elements.html +15 -9
- data/spec/html/non_control_elements.html +4 -2
- data/spec/ie_spec.rb +82 -48
- data/spec/image_spec.rb +83 -100
- data/spec/images_spec.rb +10 -10
- data/spec/label_spec.rb +29 -29
- data/spec/labels_spec.rb +10 -10
- data/spec/li_spec.rb +41 -41
- data/spec/link_spec.rb +65 -59
- data/spec/links_spec.rb +11 -11
- data/spec/lis_spec.rb +10 -10
- data/spec/map_spec.rb +30 -30
- data/spec/maps_spec.rb +10 -10
- data/spec/p_spec.rb +49 -49
- data/spec/pre_spec.rb +41 -41
- data/spec/pres_spec.rb +10 -10
- data/spec/ps_spec.rb +10 -10
- data/spec/radio_spec.rb +104 -97
- data/spec/radios_spec.rb +11 -11
- data/spec/select_list_spec.rb +118 -106
- data/spec/select_lists_spec.rb +15 -15
- data/spec/span_spec.rb +54 -54
- data/spec/spans_spec.rb +11 -11
- data/spec/spec.opts +1 -1
- data/spec/spec_helper.rb +23 -3
- data/spec/table_bodies.rb +8 -8
- data/spec/table_bodies_spec.rb +9 -9
- data/spec/table_body_spec.rb +28 -27
- data/spec/table_cell_spec.rb +25 -25
- data/spec/table_cells_spec.rb +16 -16
- data/spec/table_row_spec.rb +16 -16
- data/spec/table_rows_spec.rb +12 -12
- data/spec/table_spec.rb +36 -36
- data/spec/tables_spec.rb +12 -12
- data/spec/text_field_spec.rb +111 -92
- data/spec/text_fields_spec.rb +13 -13
- data/tasks/benchmark.rake +3 -0
- data/tasks/rspec.rake +2 -2
- data/tasks/testserver.rake +15 -0
- metadata +58 -46
- data/tasks/simple_ci.rake +0 -94
data/spec/pre_spec.rb
CHANGED
@@ -3,108 +3,108 @@ require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
3
3
|
describe "Pre" do
|
4
4
|
|
5
5
|
before :all do
|
6
|
-
@
|
7
|
-
add_spec_checker(@
|
6
|
+
@browser = IE.new
|
7
|
+
add_spec_checker(@browser)
|
8
8
|
end
|
9
9
|
|
10
10
|
before :each do
|
11
|
-
@
|
11
|
+
@browser.goto(TEST_HOST + "/non_control_elements.html")
|
12
12
|
end
|
13
13
|
|
14
14
|
# Exists method
|
15
15
|
describe "#exist?" do
|
16
16
|
it "should return true if the 'p' exists" do
|
17
|
-
@
|
18
|
-
@
|
19
|
-
@
|
20
|
-
@
|
21
|
-
@
|
22
|
-
@
|
23
|
-
@
|
24
|
-
@
|
17
|
+
@browser.pre(:id, "rspec").should exist
|
18
|
+
@browser.pre(:id, /rspec/).should exist
|
19
|
+
@browser.pre(:text, '@browser.pre(:id, "rspec").should exist').should exist
|
20
|
+
@browser.pre(:text, /@browser\.pre/).should exist
|
21
|
+
@browser.pre(:class, "ruby").should exist
|
22
|
+
@browser.pre(:class, /ruby/).should exist
|
23
|
+
@browser.pre(:index, 1).should exist
|
24
|
+
@browser.pre(:xpath, "//pre[@id='rspec']").should exist
|
25
25
|
end
|
26
26
|
it "should return false if the 'p' doesn't exist" do
|
27
|
-
@
|
28
|
-
@
|
29
|
-
@
|
30
|
-
@
|
31
|
-
@
|
32
|
-
@
|
33
|
-
@
|
34
|
-
@
|
27
|
+
@browser.pre(:id, "no_such_id").should_not exist
|
28
|
+
@browser.pre(:id, /no_such_id/).should_not exist
|
29
|
+
@browser.pre(:text, "no_such_text").should_not exist
|
30
|
+
@browser.pre(:text, /no_such_text/).should_not exist
|
31
|
+
@browser.pre(:class, "no_such_class").should_not exist
|
32
|
+
@browser.pre(:class, /no_such_class/).should_not exist
|
33
|
+
@browser.pre(:index, 1337).should_not exist
|
34
|
+
@browser.pre(:xpath, "//pre[@id='no_such_id']").should_not exist
|
35
35
|
end
|
36
|
-
it "should raise ArgumentError when what argument is
|
37
|
-
lambda { @
|
36
|
+
it "should raise ArgumentError when 'what' argument is invalid" do
|
37
|
+
lambda { @browser.pre(:id, 3.14).exists? }.should raise_error(ArgumentError)
|
38
38
|
end
|
39
|
-
it "should raise MissingWayOfFindingObjectException when how argument is
|
40
|
-
lambda { @
|
39
|
+
it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
40
|
+
lambda { @browser.pre(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
44
|
# Attribute methods
|
45
45
|
describe "#class_name" do
|
46
46
|
it "should return the class attribute" do
|
47
|
-
@
|
47
|
+
@browser.pre(:id, 'rspec').class_name.should == 'ruby'
|
48
48
|
end
|
49
49
|
it "should return an empty string if the element exists and the attribute doesn't" do
|
50
|
-
@
|
50
|
+
@browser.pre(:index, 1).class_name.should == ''
|
51
51
|
end
|
52
52
|
it "should raise UnknownObjectException if the p doesn't exist" do
|
53
|
-
lambda { @
|
53
|
+
lambda { @browser.pre(:id, 'no_such_id').class_name }.should raise_error(UnknownObjectException)
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
57
|
describe "#id" do
|
58
58
|
it "should return the id attribute" do
|
59
|
-
@
|
59
|
+
@browser.pre(:class, 'ruby').id.should == "rspec"
|
60
60
|
end
|
61
61
|
it "should return an empty string if the element exists and the attribute doesn't" do
|
62
|
-
@
|
62
|
+
@browser.pre(:index, 1).id.should == ''
|
63
63
|
end
|
64
64
|
it "should raise UnknownObjectException if the p doesn't exist" do
|
65
|
-
lambda { @
|
66
|
-
lambda { @
|
65
|
+
lambda { @browser.pre(:id, "no_such_id").id }.should raise_error(UnknownObjectException)
|
66
|
+
lambda { @browser.pre(:index, 1337).id }.should raise_error(UnknownObjectException)
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
70
|
describe "#title" do
|
71
71
|
it "should return the title attribute" do
|
72
|
-
@
|
72
|
+
@browser.pre(:class, 'brainfuck').title.should == 'The brainfuck language is an esoteric programming language noted for its extreme minimalism'
|
73
73
|
end
|
74
74
|
it "should return an empty string if the element exists and the attribute doesn't" do
|
75
|
-
@
|
75
|
+
@browser.pre(:index, 1).title.should == ''
|
76
76
|
end
|
77
77
|
it "should raise UnknownObjectException if the p doesn't exist" do
|
78
|
-
lambda { @
|
79
|
-
lambda { @
|
78
|
+
lambda { @browser.pre(:id, 'no_such_id').title }.should raise_error( UnknownObjectException)
|
79
|
+
lambda { @browser.pre(:xpath, "//pre[@id='no_such_id']").title }.should raise_error( UnknownObjectException)
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
83
83
|
describe "#text" do
|
84
84
|
it "should return the text of the p" do
|
85
|
-
@
|
85
|
+
@browser.pre(:class, 'haskell').text.should == 'main = putStrLn "Hello World"'
|
86
86
|
end
|
87
87
|
it "should return an empty string if the element doesn't contain any text" do
|
88
|
-
@
|
88
|
+
@browser.pre(:index, 1).text.should == ''
|
89
89
|
end
|
90
90
|
it "should raise UnknownObjectException if the p doesn't exist" do
|
91
|
-
lambda { @
|
92
|
-
lambda { @
|
91
|
+
lambda { @browser.pre(:id, 'no_such_id').text }.should raise_error( UnknownObjectException)
|
92
|
+
lambda { @browser.pre(:xpath , "//pre[@id='no_such_id']").text }.should raise_error( UnknownObjectException)
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
96
96
|
# Other
|
97
97
|
describe "#to_s" do
|
98
98
|
it "should return a human readable representation of the element" do
|
99
|
-
@
|
99
|
+
@browser.pre(:index, 1).to_s.should == "tag: pre"
|
100
100
|
end
|
101
101
|
it "should raise UnknownObjectException if the p doesn't exist" do
|
102
|
-
lambda { @
|
102
|
+
lambda { @browser.pre(:xpath, "//pre[@id='no_such_id']").to_s }.should raise_error( UnknownObjectException)
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
106
106
|
after :all do
|
107
|
-
@
|
107
|
+
@browser.close
|
108
108
|
end
|
109
109
|
|
110
110
|
end
|
data/spec/pres_spec.rb
CHANGED
@@ -3,38 +3,38 @@ require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
3
3
|
describe "Pres" do
|
4
4
|
|
5
5
|
before :all do
|
6
|
-
@
|
7
|
-
add_spec_checker(@
|
6
|
+
@browser = IE.new
|
7
|
+
add_spec_checker(@browser)
|
8
8
|
end
|
9
9
|
|
10
10
|
before :each do
|
11
|
-
@
|
11
|
+
@browser.goto(TEST_HOST + "/non_control_elements.html")
|
12
12
|
end
|
13
13
|
|
14
14
|
describe "#length" do
|
15
15
|
it "should return the number of pres" do
|
16
|
-
@
|
16
|
+
@browser.pres.length.should == 7
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
describe "#[]" do
|
21
21
|
it "should return the pre at the given index" do
|
22
|
-
@
|
22
|
+
@browser.pres[2].id.should == "rspec"
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
26
|
describe "#each" do
|
27
27
|
it "should iterate through pres correctly" do
|
28
|
-
@
|
29
|
-
p.name.should == @
|
30
|
-
p.id.should == @
|
31
|
-
p.value.should == @
|
28
|
+
@browser.pres.each_with_index do |p, index|
|
29
|
+
p.name.should == @browser.pre(:index, index+1).name
|
30
|
+
p.id.should == @browser.pre(:index, index+1).id
|
31
|
+
p.value.should == @browser.pre(:index, index+1).value
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
36
|
after :all do
|
37
|
-
@
|
37
|
+
@browser.close
|
38
38
|
end
|
39
39
|
|
40
40
|
end
|
data/spec/ps_spec.rb
CHANGED
@@ -2,38 +2,38 @@ require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
2
2
|
|
3
3
|
describe "Ps" do
|
4
4
|
before :all do
|
5
|
-
@
|
6
|
-
add_spec_checker(@
|
5
|
+
@browser = IE.new
|
6
|
+
add_spec_checker(@browser)
|
7
7
|
end
|
8
8
|
|
9
9
|
before :each do
|
10
|
-
@
|
10
|
+
@browser.goto(TEST_HOST + "/non_control_elements.html")
|
11
11
|
end
|
12
12
|
|
13
13
|
describe "#length" do
|
14
14
|
it "should return the number of ps" do
|
15
|
-
@
|
15
|
+
@browser.ps.length.should == 5
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
describe "#[]" do
|
20
20
|
it "should return the p at the given index" do
|
21
|
-
@
|
21
|
+
@browser.ps[1].id.should == "lead"
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
25
|
describe "#each" do
|
26
26
|
it "should iterate through ps correctly" do
|
27
|
-
@
|
28
|
-
p.name.should == @
|
29
|
-
p.id.should == @
|
30
|
-
p.value.should == @
|
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
31
|
end
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
35
|
after :all do
|
36
|
-
@
|
36
|
+
@browser.close
|
37
37
|
end
|
38
38
|
|
39
39
|
end
|
data/spec/radio_spec.rb
CHANGED
@@ -3,12 +3,12 @@ require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
3
3
|
describe "Radio" do
|
4
4
|
|
5
5
|
before :all do
|
6
|
-
@
|
7
|
-
add_spec_checker(@
|
6
|
+
@browser = IE.new
|
7
|
+
add_spec_checker(@browser)
|
8
8
|
end
|
9
9
|
|
10
10
|
before :each do
|
11
|
-
@
|
11
|
+
@browser.goto(TEST_HOST + "/forms_with_input_elements.html")
|
12
12
|
end
|
13
13
|
|
14
14
|
|
@@ -16,59 +16,60 @@ describe "Radio" do
|
|
16
16
|
|
17
17
|
describe "#exists?" do
|
18
18
|
it "should return true if the radio button exists" do
|
19
|
-
@
|
20
|
-
@
|
21
|
-
@
|
22
|
-
@
|
23
|
-
@
|
24
|
-
@
|
25
|
-
#
|
26
|
-
@
|
27
|
-
@
|
28
|
-
|
29
|
-
@
|
30
|
-
@
|
31
|
-
@
|
19
|
+
@browser.radio(:id, "new_user_newsletter_yes").should exist
|
20
|
+
@browser.radio(:id, /new_user_newsletter_yes/).should exist
|
21
|
+
@browser.radio(:name, "new_user_newsletter").should exist
|
22
|
+
@browser.radio(:name, /new_user_newsletter/).should exist
|
23
|
+
@browser.radio(:value, "yes").should exist
|
24
|
+
@browser.radio(:value, /yes/).should exist
|
25
|
+
# TODO: figure out what :text means for a radio button
|
26
|
+
# @browser.radio(:text, "yes").should exist
|
27
|
+
# @browser.radio(:text, /yes/).should exist
|
28
|
+
|
29
|
+
@browser.radio(:class, "huge").should exist
|
30
|
+
@browser.radio(:class, /huge/).should exist
|
31
|
+
@browser.radio(:index, 1).should exist
|
32
|
+
@browser.radio(:xpath, "//input[@id='new_user_newsletter_yes']").should exist
|
32
33
|
end
|
33
34
|
|
34
35
|
it "should return true if the radio button exists (search by name and value)" do
|
35
|
-
@
|
36
|
-
@
|
36
|
+
@browser.radio(:name, "new_user_newsletter", 'yes').should exist
|
37
|
+
@browser.radio(:xpath, "//input[@name='new_user_newsletter' and @value='yes']").set
|
37
38
|
end
|
38
39
|
|
39
40
|
it "should return false if the radio button does not exist" do
|
40
|
-
@
|
41
|
-
@
|
42
|
-
@
|
43
|
-
@
|
44
|
-
@
|
45
|
-
@
|
46
|
-
@
|
47
|
-
@
|
48
|
-
@
|
49
|
-
@
|
50
|
-
@
|
51
|
-
@
|
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
|
52
53
|
end
|
53
54
|
|
54
55
|
it "should return false if the radio button does not exist (search by name and value)" do
|
55
|
-
@
|
56
|
-
@
|
57
|
-
@
|
58
|
-
@
|
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
|
59
60
|
end
|
60
61
|
|
61
62
|
it "should return true for radios with a string value" do
|
62
|
-
@
|
63
|
-
@
|
63
|
+
@browser.radio(:name, 'new_user_newsletter', 'yes').should exist
|
64
|
+
@browser.radio(:name, 'new_user_newsletter', 'no').should exist
|
64
65
|
end
|
65
66
|
|
66
|
-
it "should raise ArgumentError when what argument is invalid" do
|
67
|
-
lambda { @
|
67
|
+
it "should raise ArgumentError when 'what' argument is invalid" do
|
68
|
+
lambda { @browser.radio(:id, 3.14).exists? }.should raise_error(ArgumentError)
|
68
69
|
end
|
69
70
|
|
70
|
-
it "should raise MissingWayOfFindingObjectException when how argument is invalid" do
|
71
|
-
lambda { @
|
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)
|
72
73
|
end
|
73
74
|
end
|
74
75
|
|
@@ -77,67 +78,67 @@ describe "Radio" do
|
|
77
78
|
|
78
79
|
describe "#class_name" do
|
79
80
|
it "should return the class name if the radio exists and has an attribute" do
|
80
|
-
@
|
81
|
+
@browser.radio(:id, "new_user_newsletter_yes").class_name.should == "huge"
|
81
82
|
end
|
82
83
|
it "should return an emptry string if the radio exists and the attribute doesn't" do
|
83
|
-
@
|
84
|
+
@browser.radio(:id, "new_user_newsletter_no").class_name.should == ""
|
84
85
|
end
|
85
86
|
it "should raise UnknownObjectException if the radio doesn't exist" do
|
86
|
-
lambda { @
|
87
|
+
lambda { @browser.radio(:id, "no_such_id").class_name }.should raise_error(UnknownObjectException)
|
87
88
|
end
|
88
89
|
end
|
89
90
|
|
90
91
|
describe "#id" do
|
91
92
|
it "should return the id attribute if the radio exists and has an attribute" do
|
92
|
-
@
|
93
|
+
@browser.radio(:index, 1).id.should == "new_user_newsletter_yes"
|
93
94
|
end
|
94
95
|
it "should return an emptry string if the radio exists and the attribute doesn't" do
|
95
|
-
@
|
96
|
+
@browser.radio(:index, 3).id.should == ""
|
96
97
|
end
|
97
98
|
it "should raise UnknownObjectException if the radio doesn't exist" do
|
98
|
-
lambda { @
|
99
|
+
lambda { @browser.radio(:index, 1337).id }.should raise_error(UnknownObjectException)
|
99
100
|
end
|
100
101
|
end
|
101
102
|
|
102
103
|
describe "#name" do
|
103
104
|
it "should return the name attribute if the radio exists" do
|
104
|
-
@
|
105
|
+
@browser.radio(:id, 'new_user_newsletter_yes').name.should == "new_user_newsletter"
|
105
106
|
end
|
106
107
|
it "should return an empty string if the radio exists and the attribute doesn't" do
|
107
|
-
@
|
108
|
+
@browser.radio(:id, 'new_user_newsletter_absolutely').name.should == ""
|
108
109
|
end
|
109
110
|
it "should raise UnknownObjectException if the radio doesn't exist" do
|
110
|
-
lambda { @
|
111
|
+
lambda { @browser.radio(:index, 1337).name }.should raise_error(UnknownObjectException)
|
111
112
|
end
|
112
113
|
end
|
113
114
|
|
114
115
|
describe "#title" do
|
115
116
|
it "should return the title attribute if the radio exists" do
|
116
|
-
@
|
117
|
+
@browser.radio(:id, "new_user_newsletter_no").title.should == "Traitor!"
|
117
118
|
end
|
118
119
|
it "should return an emptry string if the radio exists and the attribute doesn't" do
|
119
|
-
@
|
120
|
+
@browser.radio(:id, "new_user_newsletter_yes").title.should == ""
|
120
121
|
end
|
121
122
|
it "should raise UnknownObjectException if the radio doesn't exist" do
|
122
|
-
lambda { @
|
123
|
+
lambda { @browser.radio(:index, 1337).title }.should raise_error(UnknownObjectException)
|
123
124
|
end
|
124
125
|
end
|
125
126
|
|
126
127
|
describe "#type" do
|
127
128
|
it "should return the type attribute if the radio exists" do
|
128
|
-
@
|
129
|
+
@browser.radio(:index, 1).type.should == "radio"
|
129
130
|
end
|
130
131
|
it "should raise UnknownObjectException if the radio doesn't exist" do
|
131
|
-
lambda { @
|
132
|
+
lambda { @browser.radio(:index, 1337).type }.should raise_error(UnknownObjectException)
|
132
133
|
end
|
133
134
|
end
|
134
135
|
|
135
136
|
describe "#value" do
|
136
137
|
it "should return the value attribute if the radio exists" do
|
137
|
-
@
|
138
|
+
@browser.radio(:id, 'new_user_newsletter_yes').value.should == 'yes'
|
138
139
|
end
|
139
140
|
it "should raise UnknownObjectException if the radio doesn't exist" do
|
140
|
-
lambda { @
|
141
|
+
lambda { @browser.radio(:index, 1337).value}.should raise_error(UnknownObjectException)
|
141
142
|
end
|
142
143
|
end
|
143
144
|
|
@@ -146,28 +147,28 @@ describe "Radio" do
|
|
146
147
|
|
147
148
|
describe "#enabled?" do
|
148
149
|
it "should return true if the radio button is enabled" do
|
149
|
-
@
|
150
|
-
@
|
150
|
+
@browser.radio(:id, "new_user_newsletter_yes").should be_enabled
|
151
|
+
@browser.radio(:xpath, "//input[@id='new_user_newsletter_yes']").should be_enabled
|
151
152
|
end
|
152
153
|
it "should return false if the radio button is disabled" do
|
153
|
-
@
|
154
|
-
@
|
154
|
+
@browser.radio(:id, "new_user_newsletter_nah").should_not be_enabled
|
155
|
+
@browser.radio(:xpath,"//input[@id='new_user_newsletter_nah']").should_not be_enabled
|
155
156
|
end
|
156
157
|
it "should raise UnknownObjectException if the radio button doesn't exist" do
|
157
|
-
lambda { @
|
158
|
-
lambda { @
|
158
|
+
lambda { @browser.radio(:id, "no_such_id").enabled? }.should raise_error(UnknownObjectException)
|
159
|
+
lambda { @browser.radio(:xpath, "//input[@id='no_such_id']").enabled? }.should raise_error(UnknownObjectException)
|
159
160
|
end
|
160
161
|
end
|
161
162
|
|
162
163
|
describe "#disabled?" do
|
163
164
|
it "should return true if the radio is disabled" do
|
164
|
-
@
|
165
|
+
@browser.radio(:id, 'new_user_newsletter_nah').should be_disabled
|
165
166
|
end
|
166
167
|
it "should return false if the radio is enabled" do
|
167
|
-
@
|
168
|
+
@browser.radio(:id, 'new_user_newsletter_yes').should_not be_disabled
|
168
169
|
end
|
169
170
|
it "should raise UnknownObjectException if the radio doesn't exist" do
|
170
|
-
lambda { @
|
171
|
+
lambda { @browser.radio(:index, 1337).disabled? }.should raise_error(UnknownObjectException)
|
171
172
|
end
|
172
173
|
end
|
173
174
|
|
@@ -176,43 +177,49 @@ describe "Radio" do
|
|
176
177
|
|
177
178
|
describe "clear" do
|
178
179
|
it "should clear the radio button if it is set" do
|
179
|
-
@
|
180
|
-
@
|
180
|
+
@browser.radio(:id, "new_user_newsletter_yes").clear
|
181
|
+
@browser.radio(:id, "new_user_newsletter_yes").should_not be_set
|
181
182
|
end
|
182
183
|
it "should clear the radio button when found by :xpath" do
|
183
|
-
@
|
184
|
-
@
|
184
|
+
@browser.radio(:xpath, "//input[@id='new_user_newsletter_yes']").clear
|
185
|
+
@browser.radio(:xpath, "//input[@id='new_user_newsletter_yes']").should_not be_set
|
185
186
|
end
|
186
187
|
it "should raise UnknownObjectException if the radio button doesn't exist" do
|
187
|
-
lambda { @
|
188
|
-
lambda { @
|
188
|
+
lambda { @browser.radio(:name, "no_such_id").clear }.should raise_error(UnknownObjectException)
|
189
|
+
lambda { @browser.radio(:xpath, "//input[@id='no_such_id']").clear }.should raise_error(UnknownObjectException)
|
189
190
|
end
|
190
191
|
it "should raise ObjectDisabledException if the radio is disabled" do
|
191
|
-
@
|
192
|
-
lambda { @
|
193
|
-
lambda { @
|
192
|
+
@browser.radio(:id, "new_user_newsletter_nah").should_not be_set
|
193
|
+
lambda { @browser.radio(:id, "new_user_newsletter_nah").clear }.should raise_error(ObjectDisabledException)
|
194
|
+
lambda { @browser.radio(:xpath, "//input[@id='new_user_newsletter_nah']").clear }.should raise_error(ObjectDisabledException)
|
194
195
|
end
|
195
196
|
end
|
196
197
|
|
197
198
|
describe "#set" do
|
198
199
|
it "should set the radio button" do
|
199
|
-
@
|
200
|
-
@
|
200
|
+
@browser.radio(:id, "new_user_newsletter_no").set
|
201
|
+
@browser.radio(:id, "new_user_newsletter_no").should be_set
|
201
202
|
end
|
202
203
|
it "should set the radio button when found by :xpath" do
|
203
|
-
@
|
204
|
-
@
|
204
|
+
@browser.radio(:xpath, "//input[@id='new_user_newsletter_no']").set
|
205
|
+
@browser.radio(:xpath, "//input[@id='new_user_newsletter_no']").should be_set
|
205
206
|
end
|
206
207
|
|
207
|
-
it "should fire the onclick event"
|
208
|
+
it "should fire the onclick event" do
|
209
|
+
@browser.div(:id, "wants_newsletter").text.should be_empty
|
210
|
+
@browser.radio(:id, "new_user_newsletter_no").set
|
211
|
+
@browser.div(:id, "wants_newsletter").text.should == @browser.radio(:id, "new_user_newsletter_no").title
|
212
|
+
@browser.radio(:id, "new_user_newsletter_yes").set
|
213
|
+
@browser.div(:id, "wants_newsletter").text.should be_empty
|
214
|
+
end
|
208
215
|
|
209
216
|
it "should raise UnknownObjectException if the radio button doesn't exist" do
|
210
|
-
lambda { @
|
211
|
-
lambda { @
|
217
|
+
lambda { @browser.radio(:name, "no_such_name").set }.should raise_error(UnknownObjectException)
|
218
|
+
lambda { @browser.radio(:xpath, "//input[@name='no_such_name']").set }.should raise_error(UnknownObjectException)
|
212
219
|
end
|
213
220
|
it "should raise ObjectDisabledException if the radio is disabled" do
|
214
|
-
lambda { @
|
215
|
-
lambda { @
|
221
|
+
lambda { @browser.radio(:id, "new_user_newsletter_nah").set }.should raise_error(ObjectDisabledException)
|
222
|
+
lambda { @browser.radio(:xpath, "//input[@id='new_user_newsletter_nah']").set }.should raise_error(ObjectDisabledException )
|
216
223
|
end
|
217
224
|
end
|
218
225
|
|
@@ -221,39 +228,39 @@ describe "Radio" do
|
|
221
228
|
|
222
229
|
describe '#set?' do
|
223
230
|
it "should return true if the radio button is set" do
|
224
|
-
@
|
231
|
+
@browser.radio(:id, "new_user_newsletter_yes").should be_set
|
225
232
|
end
|
226
233
|
it "should return false if the radio button unset" do
|
227
|
-
@
|
234
|
+
@browser.radio(:id, "new_user_newsletter_no").should_not be_set
|
228
235
|
end
|
229
236
|
it "should return the state for radios with string values" do
|
230
|
-
@
|
231
|
-
@
|
232
|
-
@
|
233
|
-
@
|
234
|
-
@
|
237
|
+
@browser.radio(:name, "new_user_newsletter", 'no').should_not be_set
|
238
|
+
@browser.radio(:name, "new_user_newsletter", 'no').set
|
239
|
+
@browser.radio(:name, "new_user_newsletter", 'no').should be_set
|
240
|
+
@browser.radio(:name, "new_user_newsletter", 'no').clear
|
241
|
+
@browser.radio(:name, "new_user_newsletter", 'no').should_not be_set
|
235
242
|
end
|
236
243
|
it "should raise UnknownObjectException if the radio button doesn't exist" do
|
237
|
-
lambda { @
|
238
|
-
lambda { @
|
244
|
+
lambda { @browser.radio(:id, "no_such_id").set? }.should raise_error(UnknownObjectException)
|
245
|
+
lambda { @browser.radio(:xpath, "//input[@id='no_such_id']").set? }.should raise_error(UnknownObjectException)
|
239
246
|
end
|
240
247
|
end
|
241
248
|
|
242
249
|
describe "#get_state" do
|
243
250
|
it "should return true if the radio is set" do
|
244
|
-
@
|
251
|
+
@browser.radio(:id, "new_user_newsletter_yes").get_state.should be_true
|
245
252
|
end
|
246
253
|
it "should return false if the radio is unset" do
|
247
|
-
@
|
254
|
+
@browser.radio(:id, "new_user_newsletter_no").get_state.should be_false
|
248
255
|
end
|
249
256
|
it "should raise UnknownObjectException if the radio doesn't exist" do
|
250
|
-
lambda { @
|
251
|
-
lambda { @
|
257
|
+
lambda { @browser.radio(:name, "no_such_name").get_state }.should raise_error(UnknownObjectException)
|
258
|
+
lambda { @browser.radio(:xpath, "//input[@name='no_such_name']").get_state }.should raise_error(UnknownObjectException)
|
252
259
|
end
|
253
260
|
end
|
254
261
|
|
255
262
|
after :all do
|
256
|
-
@
|
263
|
+
@browser.close
|
257
264
|
end
|
258
265
|
|
259
266
|
end
|