celerity 0.0.1
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 +4 -0
- data/License.txt +621 -0
- data/README.txt +58 -0
- data/Rakefile +4 -0
- data/lib/celerity.rb +47 -0
- data/lib/celerity/clickable_element.rb +11 -0
- data/lib/celerity/collections.rb +99 -0
- data/lib/celerity/container.rb +369 -0
- data/lib/celerity/disabled_element.rb +20 -0
- data/lib/celerity/element.rb +114 -0
- data/lib/celerity/element_collections.rb +67 -0
- data/lib/celerity/elements/button.rb +13 -0
- data/lib/celerity/elements/file_field.rb +12 -0
- data/lib/celerity/elements/form.rb +15 -0
- data/lib/celerity/elements/frame.rb +44 -0
- data/lib/celerity/elements/image.rb +70 -0
- data/lib/celerity/elements/label.rb +10 -0
- data/lib/celerity/elements/link.rb +13 -0
- data/lib/celerity/elements/radio_check.rb +59 -0
- data/lib/celerity/elements/select_list.rb +84 -0
- data/lib/celerity/elements/table.rb +94 -0
- data/lib/celerity/elements/table_body.rb +38 -0
- data/lib/celerity/elements/table_cell.rb +30 -0
- data/lib/celerity/elements/table_row.rb +34 -0
- data/lib/celerity/elements/text_field.rb +80 -0
- data/lib/celerity/exception.rb +48 -0
- data/lib/celerity/htmlunit/commons-codec-1.3.jar +0 -0
- data/lib/celerity/htmlunit/commons-collections-3.2.jar +0 -0
- data/lib/celerity/htmlunit/commons-httpclient-3.1.jar +0 -0
- data/lib/celerity/htmlunit/commons-io-1.4.jar +0 -0
- data/lib/celerity/htmlunit/commons-lang-2.4.jar +0 -0
- data/lib/celerity/htmlunit/commons-logging-1.1.1.jar +0 -0
- data/lib/celerity/htmlunit/cssparser-0.9.5.jar +0 -0
- data/lib/celerity/htmlunit/htmlunit-2.2-SNAPSHOT.jar +0 -0
- data/lib/celerity/htmlunit/js-1.7R1.jar +0 -0
- data/lib/celerity/htmlunit/nekohtml-1.9.7.jar +0 -0
- data/lib/celerity/htmlunit/sac-1.3.jar +0 -0
- data/lib/celerity/htmlunit/xalan-2.7.0.jar +0 -0
- data/lib/celerity/htmlunit/xercesImpl-2.8.1.jar +0 -0
- data/lib/celerity/htmlunit/xml-apis-1.0.b2.jar +0 -0
- data/lib/celerity/ie.rb +126 -0
- data/lib/celerity/input_element.rb +29 -0
- data/lib/celerity/non_control_elements.rb +50 -0
- data/lib/celerity/version.rb +9 -0
- data/setup.rb +1585 -0
- data/spec/area_spec.rb +79 -0
- data/spec/areas_spec.rb +41 -0
- data/spec/button_spec.rb +171 -0
- data/spec/buttons_spec.rb +40 -0
- data/spec/checkbox_spec.rb +259 -0
- data/spec/checkboxes_spec.rb +39 -0
- data/spec/div_spec.rb +174 -0
- data/spec/divs_spec.rb +40 -0
- data/spec/element_spec.rb +29 -0
- data/spec/filefield_spec.rb +110 -0
- data/spec/filefields_spec.rb +41 -0
- data/spec/form_spec.rb +53 -0
- data/spec/forms_spec.rb +42 -0
- data/spec/frame_spec.rb +103 -0
- data/spec/hidden_spec.rb +105 -0
- data/spec/hiddens_spec.rb +40 -0
- data/spec/html/forms_with_input_elements.html +107 -0
- data/spec/html/frame_1.html +17 -0
- data/spec/html/frame_2.html +16 -0
- data/spec/html/frames.html +11 -0
- data/spec/html/iframes.html +12 -0
- data/spec/html/images.html +24 -0
- 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/non_control_elements.html +85 -0
- data/spec/html/tables.html +119 -0
- data/spec/ie_spec.rb +146 -0
- data/spec/image_spec.rb +210 -0
- data/spec/images_spec.rb +39 -0
- data/spec/label_spec.rb +65 -0
- data/spec/labels_spec.rb +41 -0
- data/spec/li_spec.rb +114 -0
- data/spec/link_spec.rb +147 -0
- data/spec/links_spec.rb +43 -0
- data/spec/lis_spec.rb +40 -0
- data/spec/map_spec.rb +83 -0
- data/spec/maps_spec.rb +41 -0
- data/spec/p_spec.rb +140 -0
- data/spec/pre_spec.rb +110 -0
- data/spec/pres_spec.rb +41 -0
- data/spec/ps_spec.rb +40 -0
- data/spec/radio_spec.rb +260 -0
- data/spec/radios_spec.rb +43 -0
- data/spec/select_list_spec.rb +286 -0
- data/spec/select_lists_spec.rb +47 -0
- data/spec/span_spec.rb +156 -0
- data/spec/spans_spec.rb +65 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +90 -0
- data/spec/table_bodies.rb +40 -0
- data/spec/table_bodies_spec.rb +42 -0
- data/spec/table_body_spec.rb +72 -0
- data/spec/table_cell_spec.rb +61 -0
- data/spec/table_cells_spec.rb +60 -0
- data/spec/table_row_spec.rb +59 -0
- data/spec/table_rows_spec.rb +57 -0
- data/spec/table_spec.rb +111 -0
- data/spec/tables_spec.rb +42 -0
- data/spec/text_field_spec.rb +234 -0
- data/spec/text_fields_spec.rb +45 -0
- data/tasks/environment.rake +7 -0
- data/tasks/rspec.rake +23 -0
- data/tasks/simple_ci.rake +94 -0
- data/tasks/testserver.rake +17 -0
- metadata +174 -0
data/spec/images_spec.rb
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
2
|
+
|
|
3
|
+
describe "Images" do
|
|
4
|
+
before :all do
|
|
5
|
+
@ie = IE.new
|
|
6
|
+
add_spec_checker(@ie)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
before :each do
|
|
10
|
+
@ie.goto(TEST_HOST + "/images.html")
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
describe "#length" do
|
|
14
|
+
it "should return the number of images" do
|
|
15
|
+
@ie.images.length.should == 8
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
describe "#[]" do
|
|
20
|
+
it "should return the image at the given index" do
|
|
21
|
+
@ie.images[6].id.should == "square"
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
describe "#each" do
|
|
26
|
+
it "should iterate through images correctly" do
|
|
27
|
+
@ie.images.each_with_index do |c, index|
|
|
28
|
+
c.name.should == @ie.image(:index, index+1).name
|
|
29
|
+
c.id.should == @ie.image(:index, index+1).id
|
|
30
|
+
c.value.should == @ie.image(:index, index+1).value
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
after :all do
|
|
36
|
+
@ie.close
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
end
|
data/spec/label_spec.rb
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
2
|
+
|
|
3
|
+
# TODO: specs for exceptions
|
|
4
|
+
|
|
5
|
+
describe "TextField" do
|
|
6
|
+
|
|
7
|
+
before :all do
|
|
8
|
+
@ie = IE.new
|
|
9
|
+
add_spec_checker(@ie)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
before :each do
|
|
13
|
+
@ie.goto(TEST_HOST + "/forms_with_input_elements.html")
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Exists method
|
|
17
|
+
describe "#exists?" do
|
|
18
|
+
it "should return true if the element exists" do
|
|
19
|
+
@ie.label(:id, 'first_label').should exist
|
|
20
|
+
@ie.label(:id, /first_label/).should exist
|
|
21
|
+
@ie.label(:text, 'First name').should exist
|
|
22
|
+
@ie.label(:text, /First name/).should exist
|
|
23
|
+
@ie.label(:index, 1).should exist
|
|
24
|
+
@ie.label(:xpath, "//label[@id='first_label']").should exist
|
|
25
|
+
end
|
|
26
|
+
it "should return false if the element does not exist" do
|
|
27
|
+
@ie.label(:id, 'no_such_id').should_not exist
|
|
28
|
+
@ie.label(:id, /no_such_id/).should_not exist
|
|
29
|
+
@ie.label(:text, 'no_such_text').should_not exist
|
|
30
|
+
@ie.label(:text, /no_such_text/).should_not exist
|
|
31
|
+
@ie.label(:index, 1337).should_not exist
|
|
32
|
+
@ie.label(:xpath, "//input[@id='no_such_id']").should_not exist
|
|
33
|
+
end
|
|
34
|
+
it "should raise ArgumentError when what argument is invalid" do
|
|
35
|
+
lambda { @ie.label(:id, 3.14).exists? }.should raise_error(ArgumentError)
|
|
36
|
+
end
|
|
37
|
+
it "should raise MissingWayOfFindingObjectException when how argument is invalid" do
|
|
38
|
+
lambda { @ie.label(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Attribute methods
|
|
43
|
+
describe "#id" do
|
|
44
|
+
it "should return the id attribute if the text field exists" do
|
|
45
|
+
@ie.label(:index, 1).id.should == "first_label"
|
|
46
|
+
end
|
|
47
|
+
it "should raise UnknownObjectException if the text field doesn't exist" do
|
|
48
|
+
lambda { @ie.label(:index, 1337).id }.should raise_error(UnknownObjectException)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
describe "#for" do
|
|
53
|
+
it "should return the id attribute if the text field exists" do
|
|
54
|
+
@ie.label(:index, 1).for.should == "new_user_first_name"
|
|
55
|
+
end
|
|
56
|
+
it "should raise UnknownObjectException if the text field doesn't exist" do
|
|
57
|
+
lambda { @ie.label(:index, 1337).for }.should raise_error(UnknownObjectException)
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
after :all do
|
|
62
|
+
@ie.close
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
data/spec/labels_spec.rb
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
2
|
+
|
|
3
|
+
describe "Labels" do
|
|
4
|
+
|
|
5
|
+
before :all do
|
|
6
|
+
@ie = IE.new
|
|
7
|
+
add_spec_checker(@ie)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
before :each do
|
|
11
|
+
@ie.goto(TEST_HOST + "/forms_with_input_elements.html")
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
describe "#length" do
|
|
15
|
+
it "should return the number of labels" do
|
|
16
|
+
@ie.labels.length.should == 25
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
describe "#[]" do
|
|
21
|
+
it "should return the pre at the given index" do
|
|
22
|
+
@ie.labels[1].id.should == "first_label"
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
describe "#each" do
|
|
27
|
+
it "should iterate through labels correctly" do
|
|
28
|
+
@ie.labels.each_with_index do |l, index|
|
|
29
|
+
l.name.should == @ie.label(:index, index+1).name
|
|
30
|
+
l.id.should == @ie.label(:index, index+1).id
|
|
31
|
+
l.value.should == @ie.label(:index, index+1).value
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
after :all do
|
|
37
|
+
@ie.close
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
end
|
|
41
|
+
|
data/spec/li_spec.rb
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
2
|
+
|
|
3
|
+
describe "Li" do
|
|
4
|
+
|
|
5
|
+
before :all do
|
|
6
|
+
@ie = IE.new
|
|
7
|
+
add_spec_checker(@ie)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
before :each do
|
|
11
|
+
@ie.goto(TEST_HOST + "/non_control_elements.html")
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# Exists method
|
|
15
|
+
describe "#exist?" do
|
|
16
|
+
it "should return true if the 'p' exists" do
|
|
17
|
+
@ie.li(:id, "non_link_1").should exist
|
|
18
|
+
@ie.li(:id, /non_link_1/).should exist
|
|
19
|
+
@ie.li(:text, "Non-link 3").should exist
|
|
20
|
+
@ie.li(:text, /Non-link 3/).should exist
|
|
21
|
+
@ie.li(:class, "nonlink").should exist
|
|
22
|
+
@ie.li(:class, /nonlink/).should exist
|
|
23
|
+
@ie.li(:index, 1).should exist
|
|
24
|
+
@ie.li(:xpath, "//li[@id='non_link_1']").should exist
|
|
25
|
+
end
|
|
26
|
+
it "should return false if the 'p' doesn't exist" do
|
|
27
|
+
@ie.li(:id, "no_such_id").should_not exist
|
|
28
|
+
@ie.li(:id, /no_such_id/).should_not exist
|
|
29
|
+
@ie.li(:text, "no_such_text").should_not exist
|
|
30
|
+
@ie.li(:text, /no_such_text/).should_not exist
|
|
31
|
+
@ie.li(:class, "no_such_class").should_not exist
|
|
32
|
+
@ie.li(:class, /no_such_class/).should_not exist
|
|
33
|
+
@ie.li(:index, 1337).should_not exist
|
|
34
|
+
@ie.li(:xpath, "//li[@id='no_such_id']").should_not exist
|
|
35
|
+
end
|
|
36
|
+
it "should raise ArgumentError when what argument is invalid" do
|
|
37
|
+
lambda { @ie.li(:id, 3.14).exists? }.should raise_error(ArgumentError)
|
|
38
|
+
end
|
|
39
|
+
it "should raise MissingWayOfFindingObjectException when how argument is invalid" do
|
|
40
|
+
lambda { @ie.li(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Attribute methods
|
|
45
|
+
describe "#class_name" do
|
|
46
|
+
it "should return the class attribute" do
|
|
47
|
+
@ie.li(:id, 'non_link_1').class_name.should == 'nonlink'
|
|
48
|
+
end
|
|
49
|
+
it "should return an empty string if the element exists and the attribute doesn't" do
|
|
50
|
+
@ie.li(:index, 1).class_name.should == ''
|
|
51
|
+
end
|
|
52
|
+
it "should raise UnknownObjectException if the p doesn't exist" do
|
|
53
|
+
lambda { @ie.li(:id, 'no_such_id').class_name }.should raise_error(UnknownObjectException)
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
describe "#id" do
|
|
58
|
+
it "should return the id attribute" do
|
|
59
|
+
@ie.li(:class, 'nonlink').id.should == "non_link_1"
|
|
60
|
+
end
|
|
61
|
+
it "should return an empty string if the element exists and the attribute doesn't" do
|
|
62
|
+
@ie.li(:index, 1).id.should == ''
|
|
63
|
+
end
|
|
64
|
+
it "should raise UnknownObjectException if the p doesn't exist" do
|
|
65
|
+
lambda { @ie.li(:id, "no_such_id").id }.should raise_error(UnknownObjectException)
|
|
66
|
+
lambda { @ie.li(:index, 1337).id }.should raise_error(UnknownObjectException)
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
describe "#title" do
|
|
71
|
+
it "should return the title attribute" do
|
|
72
|
+
@ie.li(:id, 'non_link_1').title.should == 'This is not a link!'
|
|
73
|
+
end
|
|
74
|
+
it "should return an empty string if the element exists and the attribute doesn't" do
|
|
75
|
+
@ie.li(:index, 1).title.should == ''
|
|
76
|
+
end
|
|
77
|
+
it "should raise UnknownObjectException if the p doesn't exist" do
|
|
78
|
+
lambda { @ie.li(:id, 'no_such_id').title }.should raise_error( UnknownObjectException)
|
|
79
|
+
lambda { @ie.li(:xpath, "//li[@id='no_such_id']").title }.should raise_error( UnknownObjectException)
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
describe "#text" do
|
|
84
|
+
it "should return the text of the p" do
|
|
85
|
+
@ie.li(:id, 'non_link_1').text.should == 'Non-link 1'
|
|
86
|
+
end
|
|
87
|
+
it "should return an empty string if the element doesn't contain any text" do
|
|
88
|
+
@ie.li(:index, 1).text.should == ''
|
|
89
|
+
end
|
|
90
|
+
it "should raise UnknownObjectException if the p doesn't exist" do
|
|
91
|
+
lambda { @ie.li(:id, 'no_such_id').text }.should raise_error( UnknownObjectException)
|
|
92
|
+
lambda { @ie.li(:xpath , "//li[@id='no_such_id']").text }.should raise_error( UnknownObjectException)
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# Other
|
|
97
|
+
describe "#to_s" do
|
|
98
|
+
it "should return a human readable representation of the element" do
|
|
99
|
+
@ie.li(:id, 'non_link_1').to_s.should == "tag: li\n" +
|
|
100
|
+
" id: non_link_1\n" +
|
|
101
|
+
" class: nonlink\n" +
|
|
102
|
+
" title: This is not a link!\n" +
|
|
103
|
+
" text: Non-link 1"
|
|
104
|
+
end
|
|
105
|
+
it "should raise UnknownObjectException if the p doesn't exist" do
|
|
106
|
+
lambda { @ie.li(:xpath, "//li[@id='no_such_id']").to_s }.should raise_error( UnknownObjectException)
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
after :all do
|
|
111
|
+
@ie.close
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
end
|
data/spec/link_spec.rb
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
2
|
+
|
|
3
|
+
describe "Link" do
|
|
4
|
+
before :all do
|
|
5
|
+
@ie = IE.new
|
|
6
|
+
add_spec_checker(@ie)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
before :each do
|
|
10
|
+
@ie.goto(TEST_HOST + "/non_control_elements.html")
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# Exists method
|
|
14
|
+
describe "#exist?" do
|
|
15
|
+
it "should return true if the link exists" do
|
|
16
|
+
@ie.link(:id, 'link_2').should exist
|
|
17
|
+
@ie.link(:id, /link_2/).should exist
|
|
18
|
+
@ie.link(:name, 'bad_attribute').should exist
|
|
19
|
+
@ie.link(:name, /bad_attribute/).should exist
|
|
20
|
+
@ie.link(:title, "link_title_2").should exist
|
|
21
|
+
@ie.link(:title, /link_title_2/).should exist
|
|
22
|
+
@ie.link(:text, "Link 2").should exist
|
|
23
|
+
@ie.link(:text, /Link 2/i).should exist
|
|
24
|
+
@ie.link(:url, 'non_control_elements.html').should exist
|
|
25
|
+
@ie.link(:url, /non_control_elements.html/).should exist
|
|
26
|
+
@ie.link(:index, 2).should exist
|
|
27
|
+
@ie.link(:xpath, "//a[@id='link_2']").should exist
|
|
28
|
+
end
|
|
29
|
+
it "should return false if the link doesn't exist" do
|
|
30
|
+
@ie.link(:id, 'no_such_id').should_not exist
|
|
31
|
+
@ie.link(:id, /no_such_id/).should_not exist
|
|
32
|
+
@ie.link(:name, 'no_such_name').should_not exist
|
|
33
|
+
@ie.link(:name, /no_such_name/).should_not exist
|
|
34
|
+
@ie.link(:title, "no_such_title").should_not exist
|
|
35
|
+
@ie.link(:title, /no_such_title/).should_not exist
|
|
36
|
+
@ie.link(:text, "no_such_text").should_not exist
|
|
37
|
+
@ie.link(:text, /no_such_text/i).should_not exist
|
|
38
|
+
@ie.link(:url, 'no_such_href').should_not exist
|
|
39
|
+
@ie.link(:url, /no_such_href/).should_not exist
|
|
40
|
+
@ie.link(:index, 1337).should_not exist
|
|
41
|
+
@ie.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 { @ie.link(:id, 3.14).exists? }.should raise_error(ArgumentError)
|
|
45
|
+
end
|
|
46
|
+
it "should raise MissingWayOfFindingObjectException when how argument is invalid" do
|
|
47
|
+
lambda { @ie.link(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# Attribute methods
|
|
52
|
+
describe "#class_name" do
|
|
53
|
+
it "should return the type attribute if the link exists" do
|
|
54
|
+
@ie.link(:index, 2).class_name.should == "external"
|
|
55
|
+
end
|
|
56
|
+
it "should return an empty string if the link exists and the attribute doesn't" do
|
|
57
|
+
@ie.link(:index, 1).class_name.should == ''
|
|
58
|
+
end
|
|
59
|
+
it "should raise an UnknownObjectException if the link doesn't exist" do
|
|
60
|
+
lambda { @ie.link(:index, 1337).class_name }.should raise_error(UnknownObjectException)
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
describe "#href" do
|
|
65
|
+
it "should return the href attribute if the link exists" do
|
|
66
|
+
@ie.link(:index, 2).href.should match(/non_control_elements/)
|
|
67
|
+
end
|
|
68
|
+
it "should return an empty string if the link exists and the attribute doesn't" do
|
|
69
|
+
@ie.link(:index, 1).href.should == ""
|
|
70
|
+
end
|
|
71
|
+
it "should raise an UnknownObjectException if the link doesn't exist" do
|
|
72
|
+
lambda { @ie.link(:index, 1337).href }.should raise_error(UnknownObjectException)
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
describe "#id" do
|
|
77
|
+
it "should return the id attribute if the link exists" do
|
|
78
|
+
@ie.link(:index, 2).id.should == "link_2"
|
|
79
|
+
end
|
|
80
|
+
it "should return an empty string if the link exists and the attribute doesn't" do
|
|
81
|
+
@ie.link(:index, 1).id.should == ""
|
|
82
|
+
end
|
|
83
|
+
it "should raise an UnknownObjectException if the link doesn't exist" do
|
|
84
|
+
lambda { @ie.link(:index, 1337).id }.should raise_error(UnknownObjectException)
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
describe "#name" do
|
|
89
|
+
it "should return the name attribute if the link exists" do
|
|
90
|
+
@ie.link(:index, 3).name.should == "bad_attribute"
|
|
91
|
+
end
|
|
92
|
+
it "should return an empty string if the link exists and the attribute doesn't" do
|
|
93
|
+
@ie.link(:index, 1).name.should == ''
|
|
94
|
+
end
|
|
95
|
+
it "should raise an UnknownObjectException if the link doesn't exist" do
|
|
96
|
+
lambda { @ie.link(:index, 1337).name }.should raise_error(UnknownObjectException)
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
describe "#text" do
|
|
101
|
+
it "should return the link text" do
|
|
102
|
+
@ie.link(:index, 2).text.should == "Link 2"
|
|
103
|
+
end
|
|
104
|
+
it "should return an empty string if the link exists and contains no text" do
|
|
105
|
+
@ie.link(:index, 1).text.should == ""
|
|
106
|
+
end
|
|
107
|
+
it "should raise an UnknownObjectException if the link doesn't exist" do
|
|
108
|
+
lambda { @ie.link(:index, 1337).text }.should raise_error(UnknownObjectException)
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
describe "#title" do
|
|
113
|
+
it "should return the type attribute if the link exists" do
|
|
114
|
+
@ie.link(:index, 2).title.should == "link_title_2"
|
|
115
|
+
end
|
|
116
|
+
it "should return an empty string if the link exists and the attribute doesn't" do
|
|
117
|
+
@ie.link(:index, 1).title.should == ""
|
|
118
|
+
end
|
|
119
|
+
it "should raise an UnknownObjectException if the link doesn't exist" do
|
|
120
|
+
lambda { @ie.link(:index, 1337).title }.should raise_error(UnknownObjectException)
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
# Manipulation methods
|
|
125
|
+
describe "#click" do
|
|
126
|
+
it "should find an existing link by (:text, String) and click it" do
|
|
127
|
+
@ie.link(:text, "Link 3").click
|
|
128
|
+
@ie.text.include?("User administration").should be_true
|
|
129
|
+
end
|
|
130
|
+
it "should find an existing link by (:text, Regexp) and click it" do
|
|
131
|
+
@ie.link(:url, /forms_with_input_elements/).click
|
|
132
|
+
@ie.text.include?("User administration").should be_true
|
|
133
|
+
end
|
|
134
|
+
it "should find an existing link by (:index, Integer) and click it" do
|
|
135
|
+
@ie.link(:index, 3).click
|
|
136
|
+
@ie.text.include?("User administration").should be_true
|
|
137
|
+
end
|
|
138
|
+
it "should raise an UnknownObjectException if the link doesn't exist" do
|
|
139
|
+
lambda { @ie.link(:index, 1337).click }.should raise_error(UnknownObjectException)
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
after :all do
|
|
144
|
+
@ie.close
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
end
|
data/spec/links_spec.rb
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
2
|
+
|
|
3
|
+
describe "Links" do
|
|
4
|
+
before :all do
|
|
5
|
+
@ie = IE.new
|
|
6
|
+
add_spec_checker(@ie)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
before :each do
|
|
10
|
+
@ie.goto(TEST_HOST + "/non_control_elements.html")
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
describe "#length" do
|
|
14
|
+
it "should return the number of links" do
|
|
15
|
+
@ie.links.length.should == 3
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
describe "#[]" do
|
|
20
|
+
it "should return the link at the given index" do
|
|
21
|
+
@ie.links[3].id.should == "link_3"
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
describe "#each" do
|
|
26
|
+
it "should iterate through links correctly" do
|
|
27
|
+
index = 1
|
|
28
|
+
@ie.links.each do |c|
|
|
29
|
+
c.name.should == @ie.link(:index, index).name
|
|
30
|
+
c.id.should == @ie.link(:index, index).id
|
|
31
|
+
c.value.should == @ie.link(:index, index).value
|
|
32
|
+
index += 1
|
|
33
|
+
end
|
|
34
|
+
@ie.links.length.should == index - 1
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
after :all do
|
|
39
|
+
@ie.close
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
end
|
|
43
|
+
|