celerity 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- 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/images_spec.rb
CHANGED
@@ -2,38 +2,38 @@ require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
2
2
|
|
3
3
|
describe "Images" 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 + "/images.html")
|
11
11
|
end
|
12
12
|
|
13
13
|
describe "#length" do
|
14
14
|
it "should return the number of images" do
|
15
|
-
@
|
15
|
+
@browser.images.length.should == 8
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
describe "#[]" do
|
20
20
|
it "should return the image at the given index" do
|
21
|
-
@
|
21
|
+
@browser.images[6].id.should == "square"
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
25
|
describe "#each" do
|
26
26
|
it "should iterate through images correctly" do
|
27
|
-
@
|
28
|
-
c.name.should == @
|
29
|
-
c.id.should == @
|
30
|
-
c.value.should == @
|
27
|
+
@browser.images.each_with_index do |c, index|
|
28
|
+
c.name.should == @browser.image(:index, index+1).name
|
29
|
+
c.id.should == @browser.image(:index, index+1).id
|
30
|
+
c.value.should == @browser.image(: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/label_spec.rb
CHANGED
@@ -2,64 +2,64 @@ require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
2
2
|
|
3
3
|
# TODO: specs for exceptions
|
4
4
|
|
5
|
-
describe "
|
5
|
+
describe "Label" do
|
6
6
|
|
7
7
|
before :all do
|
8
|
-
@
|
9
|
-
add_spec_checker(@
|
8
|
+
@browser = IE.new
|
9
|
+
add_spec_checker(@browser)
|
10
10
|
end
|
11
11
|
|
12
12
|
before :each do
|
13
|
-
@
|
13
|
+
@browser.goto(TEST_HOST + "/forms_with_input_elements.html")
|
14
14
|
end
|
15
15
|
|
16
16
|
# Exists method
|
17
17
|
describe "#exists?" do
|
18
18
|
it "should return true if the element exists" do
|
19
|
-
@
|
20
|
-
@
|
21
|
-
@
|
22
|
-
@
|
23
|
-
@
|
24
|
-
@
|
19
|
+
@browser.label(:id, 'first_label').should exist
|
20
|
+
@browser.label(:id, /first_label/).should exist
|
21
|
+
@browser.label(:text, 'First name').should exist
|
22
|
+
@browser.label(:text, /First name/).should exist
|
23
|
+
@browser.label(:index, 1).should exist
|
24
|
+
@browser.label(:xpath, "//label[@id='first_label']").should exist
|
25
25
|
end
|
26
26
|
it "should return false if the element does not exist" do
|
27
|
-
@
|
28
|
-
@
|
29
|
-
@
|
30
|
-
@
|
31
|
-
@
|
32
|
-
@
|
27
|
+
@browser.label(:id, 'no_such_id').should_not exist
|
28
|
+
@browser.label(:id, /no_such_id/).should_not exist
|
29
|
+
@browser.label(:text, 'no_such_text').should_not exist
|
30
|
+
@browser.label(:text, /no_such_text/).should_not exist
|
31
|
+
@browser.label(:index, 1337).should_not exist
|
32
|
+
@browser.label(:xpath, "//input[@id='no_such_id']").should_not exist
|
33
33
|
end
|
34
|
-
it "should raise ArgumentError when what argument is invalid" do
|
35
|
-
lambda { @
|
34
|
+
it "should raise ArgumentError when 'what' argument is invalid" do
|
35
|
+
lambda { @browser.label(:id, 3.14).exists? }.should raise_error(ArgumentError)
|
36
36
|
end
|
37
|
-
it "should raise MissingWayOfFindingObjectException when how argument is invalid" do
|
38
|
-
lambda { @
|
37
|
+
it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
38
|
+
lambda { @browser.label(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
42
|
# Attribute methods
|
43
43
|
describe "#id" do
|
44
|
-
it "should return the id attribute if the
|
45
|
-
@
|
44
|
+
it "should return the id attribute if the label exists" do
|
45
|
+
@browser.label(:index, 1).id.should == "first_label"
|
46
46
|
end
|
47
|
-
it "should raise UnknownObjectException if the
|
48
|
-
lambda { @
|
47
|
+
it "should raise UnknownObjectException if the label doesn't exist" do
|
48
|
+
lambda { @browser.label(:index, 1337).id }.should raise_error(UnknownObjectException)
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
52
|
describe "#for" do
|
53
|
-
it "should return the
|
54
|
-
@
|
53
|
+
it "should return the 'for' attribute if the label exists" do
|
54
|
+
@browser.label(:index, 1).for.should == "new_user_first_name"
|
55
55
|
end
|
56
|
-
it "should raise UnknownObjectException if the
|
57
|
-
lambda { @
|
56
|
+
it "should raise UnknownObjectException if the label doesn't exist" do
|
57
|
+
lambda { @browser.label(:index, 1337).for }.should raise_error(UnknownObjectException)
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
61
|
after :all do
|
62
|
-
@
|
62
|
+
@browser.close
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
data/spec/labels_spec.rb
CHANGED
@@ -3,38 +3,38 @@ require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
3
3
|
describe "Labels" 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
|
describe "#length" do
|
15
15
|
it "should return the number of labels" do
|
16
|
-
@
|
16
|
+
@browser.labels.length.should == 26 # changed this from 25 - Jari
|
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.labels[1].id.should == "first_label"
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
26
|
describe "#each" do
|
27
27
|
it "should iterate through labels correctly" do
|
28
|
-
@
|
29
|
-
l.name.should == @
|
30
|
-
l.id.should == @
|
31
|
-
l.value.should == @
|
28
|
+
@browser.labels.each_with_index do |l, index|
|
29
|
+
l.name.should == @browser.label(:index, index+1).name
|
30
|
+
l.id.should == @browser.label(:index, index+1).id
|
31
|
+
l.value.should == @browser.label(: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/li_spec.rb
CHANGED
@@ -3,112 +3,112 @@ require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
3
3
|
describe "Li" 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.li(:id, "non_link_1").should exist
|
18
|
+
@browser.li(:id, /non_link_1/).should exist
|
19
|
+
@browser.li(:text, "Non-link 3").should exist
|
20
|
+
@browser.li(:text, /Non-link 3/).should exist
|
21
|
+
@browser.li(:class, "nonlink").should exist
|
22
|
+
@browser.li(:class, /nonlink/).should exist
|
23
|
+
@browser.li(:index, 1).should exist
|
24
|
+
@browser.li(:xpath, "//li[@id='non_link_1']").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.li(:id, "no_such_id").should_not exist
|
28
|
+
@browser.li(:id, /no_such_id/).should_not exist
|
29
|
+
@browser.li(:text, "no_such_text").should_not exist
|
30
|
+
@browser.li(:text, /no_such_text/).should_not exist
|
31
|
+
@browser.li(:class, "no_such_class").should_not exist
|
32
|
+
@browser.li(:class, /no_such_class/).should_not exist
|
33
|
+
@browser.li(:index, 1337).should_not exist
|
34
|
+
@browser.li(:xpath, "//li[@id='no_such_id']").should_not exist
|
35
35
|
end
|
36
|
-
it "should raise ArgumentError when what argument is invalid" do
|
37
|
-
lambda { @
|
36
|
+
it "should raise ArgumentError when 'what' argument is invalid" do
|
37
|
+
lambda { @browser.li(:id, 3.14).exists? }.should raise_error(ArgumentError)
|
38
38
|
end
|
39
|
-
it "should raise MissingWayOfFindingObjectException when how argument is invalid" do
|
40
|
-
lambda { @
|
39
|
+
it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
40
|
+
lambda { @browser.li(: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.li(:id, 'non_link_1').class_name.should == 'nonlink'
|
48
48
|
end
|
49
49
|
it "should return an empty string if the element exists and the attribute doesn't" do
|
50
|
-
@
|
50
|
+
@browser.li(: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.li(: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.li(:class, 'nonlink').id.should == "non_link_1"
|
60
60
|
end
|
61
61
|
it "should return an empty string if the element exists and the attribute doesn't" do
|
62
|
-
@
|
62
|
+
@browser.li(: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.li(:id, "no_such_id").id }.should raise_error(UnknownObjectException)
|
66
|
+
lambda { @browser.li(: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.li(:id, 'non_link_1').title.should == 'This is not a link!'
|
73
73
|
end
|
74
74
|
it "should return an empty string if the element exists and the attribute doesn't" do
|
75
|
-
@
|
75
|
+
@browser.li(: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.li(:id, 'no_such_id').title }.should raise_error( UnknownObjectException)
|
79
|
+
lambda { @browser.li(:xpath, "//li[@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.li(:id, 'non_link_1').text.should == 'Non-link 1'
|
86
86
|
end
|
87
87
|
it "should return an empty string if the element doesn't contain any text" do
|
88
|
-
@
|
88
|
+
@browser.li(: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.li(:id, 'no_such_id').text }.should raise_error( UnknownObjectException)
|
92
|
+
lambda { @browser.li(:xpath , "//li[@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.li(:id, 'non_link_1').to_s.should == "tag: li\n" +
|
100
100
|
" id: non_link_1\n" +
|
101
101
|
" class: nonlink\n" +
|
102
102
|
" title: This is not a link!\n" +
|
103
103
|
" text: Non-link 1"
|
104
104
|
end
|
105
105
|
it "should raise UnknownObjectException if the p doesn't exist" do
|
106
|
-
lambda { @
|
106
|
+
lambda { @browser.li(:xpath, "//li[@id='no_such_id']").to_s }.should raise_error( UnknownObjectException)
|
107
107
|
end
|
108
108
|
end
|
109
109
|
|
110
110
|
after :all do
|
111
|
-
@
|
111
|
+
@browser.close
|
112
112
|
end
|
113
113
|
|
114
114
|
end
|
data/spec/link_spec.rb
CHANGED
@@ -2,146 +2,152 @@ require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
2
2
|
|
3
3
|
describe "Link" 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
|
# Exists method
|
14
14
|
describe "#exist?" do
|
15
15
|
it "should return true if the link exists" do
|
16
|
-
@
|
17
|
-
@
|
18
|
-
@
|
19
|
-
@
|
20
|
-
@
|
21
|
-
@
|
22
|
-
@
|
23
|
-
@
|
24
|
-
@
|
25
|
-
@
|
26
|
-
@
|
27
|
-
@
|
16
|
+
@browser.link(:id, 'link_2').should exist
|
17
|
+
@browser.link(:id, /link_2/).should exist
|
18
|
+
@browser.link(:name, 'bad_attribute').should exist
|
19
|
+
@browser.link(:name, /bad_attribute/).should exist
|
20
|
+
@browser.link(:title, "link_title_2").should exist
|
21
|
+
@browser.link(:title, /link_title_2/).should exist
|
22
|
+
@browser.link(:text, "Link 2").should exist
|
23
|
+
@browser.link(:text, /Link 2/i).should exist
|
24
|
+
@browser.link(:url, 'non_control_elements.html').should exist
|
25
|
+
@browser.link(:url, /non_control_elements.html/).should exist
|
26
|
+
@browser.link(:index, 2).should exist
|
27
|
+
@browser.link(:xpath, "//a[@id='link_2']").should exist
|
28
28
|
end
|
29
29
|
it "should return false if the link doesn't exist" do
|
30
|
-
@
|
31
|
-
@
|
32
|
-
@
|
33
|
-
@
|
34
|
-
@
|
35
|
-
@
|
36
|
-
@
|
37
|
-
@
|
38
|
-
@
|
39
|
-
@
|
40
|
-
@
|
41
|
-
@
|
42
|
-
end
|
43
|
-
it "should raise ArgumentError when what argument is invalid" do
|
44
|
-
lambda { @
|
45
|
-
end
|
46
|
-
it "should raise MissingWayOfFindingObjectException when how argument is invalid" do
|
47
|
-
lambda { @
|
30
|
+
@browser.link(:id, 'no_such_id').should_not exist
|
31
|
+
@browser.link(:id, /no_such_id/).should_not exist
|
32
|
+
@browser.link(:name, 'no_such_name').should_not exist
|
33
|
+
@browser.link(:name, /no_such_name/).should_not exist
|
34
|
+
@browser.link(:title, "no_such_title").should_not exist
|
35
|
+
@browser.link(:title, /no_such_title/).should_not exist
|
36
|
+
@browser.link(:text, "no_such_text").should_not exist
|
37
|
+
@browser.link(:text, /no_such_text/i).should_not exist
|
38
|
+
@browser.link(:url, 'no_such_href').should_not exist
|
39
|
+
@browser.link(:url, /no_such_href/).should_not exist
|
40
|
+
@browser.link(:index, 1337).should_not exist
|
41
|
+
@browser.link(:xpath, "//a[@id='no_such_id']").should_not exist
|
42
|
+
end
|
43
|
+
it "should raise ArgumentError when 'what' argument is invalid" do
|
44
|
+
lambda { @browser.link(:id, 3.14).exists? }.should raise_error(ArgumentError)
|
45
|
+
end
|
46
|
+
it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
47
|
+
lambda { @browser.link(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
51
|
# Attribute methods
|
52
52
|
describe "#class_name" do
|
53
53
|
it "should return the type attribute if the link exists" do
|
54
|
-
@
|
54
|
+
@browser.link(:index, 2).class_name.should == "external"
|
55
55
|
end
|
56
56
|
it "should return an empty string if the link exists and the attribute doesn't" do
|
57
|
-
@
|
57
|
+
@browser.link(:index, 1).class_name.should == ''
|
58
58
|
end
|
59
59
|
it "should raise an UnknownObjectException if the link doesn't exist" do
|
60
|
-
lambda { @
|
60
|
+
lambda { @browser.link(:index, 1337).class_name }.should raise_error(UnknownObjectException)
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
64
|
describe "#href" do
|
65
65
|
it "should return the href attribute if the link exists" do
|
66
|
-
@
|
66
|
+
@browser.link(:index, 2).href.should match(/non_control_elements/)
|
67
67
|
end
|
68
68
|
it "should return an empty string if the link exists and the attribute doesn't" do
|
69
|
-
@
|
69
|
+
@browser.link(:index, 1).href.should == ""
|
70
70
|
end
|
71
71
|
it "should raise an UnknownObjectException if the link doesn't exist" do
|
72
|
-
lambda { @
|
72
|
+
lambda { @browser.link(:index, 1337).href }.should raise_error(UnknownObjectException)
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
76
|
+
describe "#url" do
|
77
|
+
it "should return the href attribute" do
|
78
|
+
@browser.link(:index, 2).url.should match(/non_control_elements/)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
76
82
|
describe "#id" do
|
77
83
|
it "should return the id attribute if the link exists" do
|
78
|
-
@
|
84
|
+
@browser.link(:index, 2).id.should == "link_2"
|
79
85
|
end
|
80
86
|
it "should return an empty string if the link exists and the attribute doesn't" do
|
81
|
-
@
|
87
|
+
@browser.link(:index, 1).id.should == ""
|
82
88
|
end
|
83
89
|
it "should raise an UnknownObjectException if the link doesn't exist" do
|
84
|
-
lambda { @
|
90
|
+
lambda { @browser.link(:index, 1337).id }.should raise_error(UnknownObjectException)
|
85
91
|
end
|
86
92
|
end
|
87
93
|
|
88
94
|
describe "#name" do
|
89
95
|
it "should return the name attribute if the link exists" do
|
90
|
-
@
|
96
|
+
@browser.link(:index, 3).name.should == "bad_attribute"
|
91
97
|
end
|
92
98
|
it "should return an empty string if the link exists and the attribute doesn't" do
|
93
|
-
@
|
99
|
+
@browser.link(:index, 1).name.should == ''
|
94
100
|
end
|
95
101
|
it "should raise an UnknownObjectException if the link doesn't exist" do
|
96
|
-
lambda { @
|
102
|
+
lambda { @browser.link(:index, 1337).name }.should raise_error(UnknownObjectException)
|
97
103
|
end
|
98
104
|
end
|
99
105
|
|
100
106
|
describe "#text" do
|
101
107
|
it "should return the link text" do
|
102
|
-
@
|
108
|
+
@browser.link(:index, 2).text.should == "Link 2"
|
103
109
|
end
|
104
110
|
it "should return an empty string if the link exists and contains no text" do
|
105
|
-
@
|
111
|
+
@browser.link(:index, 1).text.should == ""
|
106
112
|
end
|
107
113
|
it "should raise an UnknownObjectException if the link doesn't exist" do
|
108
|
-
lambda { @
|
114
|
+
lambda { @browser.link(:index, 1337).text }.should raise_error(UnknownObjectException)
|
109
115
|
end
|
110
116
|
end
|
111
117
|
|
112
118
|
describe "#title" do
|
113
119
|
it "should return the type attribute if the link exists" do
|
114
|
-
@
|
120
|
+
@browser.link(:index, 2).title.should == "link_title_2"
|
115
121
|
end
|
116
122
|
it "should return an empty string if the link exists and the attribute doesn't" do
|
117
|
-
@
|
123
|
+
@browser.link(:index, 1).title.should == ""
|
118
124
|
end
|
119
125
|
it "should raise an UnknownObjectException if the link doesn't exist" do
|
120
|
-
lambda { @
|
126
|
+
lambda { @browser.link(:index, 1337).title }.should raise_error(UnknownObjectException)
|
121
127
|
end
|
122
128
|
end
|
123
129
|
|
124
130
|
# Manipulation methods
|
125
131
|
describe "#click" do
|
126
132
|
it "should find an existing link by (:text, String) and click it" do
|
127
|
-
@
|
128
|
-
@
|
133
|
+
@browser.link(:text, "Link 3").click
|
134
|
+
@browser.text.include?("User administration").should be_true
|
129
135
|
end
|
130
136
|
it "should find an existing link by (:text, Regexp) and click it" do
|
131
|
-
@
|
132
|
-
@
|
137
|
+
@browser.link(:url, /forms_with_input_elements/).click
|
138
|
+
@browser.text.include?("User administration").should be_true
|
133
139
|
end
|
134
140
|
it "should find an existing link by (:index, Integer) and click it" do
|
135
|
-
@
|
136
|
-
@
|
141
|
+
@browser.link(:index, 3).click
|
142
|
+
@browser.text.include?("User administration").should be_true
|
137
143
|
end
|
138
144
|
it "should raise an UnknownObjectException if the link doesn't exist" do
|
139
|
-
lambda { @
|
145
|
+
lambda { @browser.link(:index, 1337).click }.should raise_error(UnknownObjectException)
|
140
146
|
end
|
141
147
|
end
|
142
148
|
|
143
149
|
after :all do
|
144
|
-
@
|
150
|
+
@browser.close
|
145
151
|
end
|
146
152
|
|
147
153
|
end
|