celerity 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/History.txt +14 -0
- data/Manifest.txt +127 -151
- data/README.txt +15 -20
- data/lib/celerity.rb +13 -5
- data/lib/celerity/browser.rb +296 -0
- data/lib/celerity/clickable_element.rb +1 -0
- data/lib/celerity/collections.rb +4 -0
- data/lib/celerity/container.rb +69 -2
- data/lib/celerity/disabled_element.rb +1 -0
- data/lib/celerity/element.rb +103 -38
- data/lib/celerity/element_collections.rb +14 -8
- data/lib/celerity/element_locator.rb +61 -50
- data/lib/celerity/element_map.rb +51 -0
- data/lib/celerity/elements/button.rb +1 -0
- data/lib/celerity/elements/file_field.rb +3 -2
- data/lib/celerity/elements/form.rb +1 -0
- data/lib/celerity/elements/frame.rb +16 -1
- data/lib/celerity/elements/image.rb +15 -13
- data/lib/celerity/elements/link.rb +4 -1
- data/lib/celerity/elements/option.rb +1 -0
- data/lib/celerity/elements/radio_check.rb +19 -7
- data/lib/celerity/elements/select_list.rb +17 -2
- data/lib/celerity/elements/table.rb +34 -20
- data/lib/celerity/elements/table_body.rb +2 -2
- data/lib/celerity/elements/table_cell.rb +3 -1
- data/lib/celerity/elements/table_footer.rb +2 -2
- data/lib/celerity/elements/table_header.rb +2 -2
- data/lib/celerity/elements/table_row.rb +4 -2
- data/lib/celerity/elements/text_field.rb +20 -9
- data/lib/celerity/exception.rb +11 -18
- data/lib/celerity/extra/method_generator.rb +13 -8
- data/lib/celerity/htmlunit/download.sh +23 -0
- data/lib/celerity/htmlunit/htmlunit-2.2.jar +0 -0
- data/lib/celerity/htmlunit/htmlunit-core-js-2.2.jar +0 -0
- data/lib/celerity/htmlunit/{nekohtml-1.9.7.jar → nekohtml-1.9.8.jar} +0 -0
- data/lib/celerity/input_element.rb +1 -1
- data/lib/celerity/version.rb +1 -1
- data/lib/celerity/watir_compatibility.rb +37 -23
- data/spec/area_spec.rb +19 -4
- data/spec/areas_spec.rb +2 -3
- data/spec/{ie_spec.rb → browser_spec.rb} +66 -15
- data/spec/button_spec.rb +36 -3
- data/spec/buttons_spec.rb +2 -3
- data/spec/checkbox_spec.rb +43 -8
- data/spec/checkboxes_spec.rb +2 -3
- data/spec/div_spec.rb +31 -4
- data/spec/divs_spec.rb +2 -3
- data/spec/element_spec.rb +36 -6
- data/spec/filefield_spec.rb +28 -13
- data/spec/filefields_spec.rb +2 -3
- data/spec/form_spec.rb +6 -3
- data/spec/forms_spec.rb +2 -3
- data/spec/frame_spec.rb +14 -5
- data/spec/frames_spec.rb +71 -0
- data/spec/hidden_spec.rb +21 -3
- data/spec/hiddens_spec.rb +2 -3
- data/spec/hn_spec.rb +30 -12
- data/spec/hns_spec.rb +14 -10
- data/spec/html/form_js_bug.html +11 -0
- data/spec/html/forms_with_input_elements.html +2 -1
- data/spec/html/invalid_js.html +11 -0
- data/spec/html/latin1_text.html +1 -0
- data/spec/html/non_control_elements.html +8 -4
- data/spec/html/simple_ajax.html +22 -0
- data/spec/htmlunit_spec.rb +4 -5
- data/spec/image_spec.rb +33 -3
- data/spec/images_spec.rb +2 -3
- data/spec/label_spec.rb +16 -3
- data/spec/labels_spec.rb +2 -3
- data/spec/li_spec.rb +25 -3
- data/spec/link_spec.rb +35 -3
- data/spec/links_spec.rb +2 -3
- data/spec/lis_spec.rb +2 -3
- data/spec/map_spec.rb +19 -3
- data/spec/maps_spec.rb +2 -3
- data/spec/meta_spec.rb +3 -1
- data/spec/ol_spec.rb +17 -3
- data/spec/ols_spec.rb +2 -3
- data/spec/option_spec.rb +28 -3
- data/spec/p_spec.rb +30 -2
- data/spec/pre_spec.rb +25 -3
- data/spec/pres_spec.rb +2 -3
- data/spec/ps_spec.rb +2 -3
- data/spec/radio_spec.rb +47 -3
- data/spec/radios_spec.rb +2 -3
- data/spec/select_list_spec.rb +42 -3
- data/spec/select_lists_spec.rb +2 -3
- data/spec/span_spec.rb +32 -7
- data/spec/spans_spec.rb +2 -4
- data/spec/spec_helper.rb +5 -25
- data/spec/table_bodies_spec.rb +7 -5
- data/spec/table_body_spec.rb +11 -4
- data/spec/table_cell_spec.rb +15 -4
- data/spec/table_cells_spec.rb +3 -4
- data/spec/table_footer_spec.rb +11 -4
- data/spec/table_footers_spec.rb +7 -5
- data/spec/table_header_spec.rb +11 -4
- data/spec/table_headers_spec.rb +7 -5
- data/spec/table_row_spec.rb +31 -7
- data/spec/table_rows_spec.rb +5 -4
- data/spec/table_spec.rb +36 -7
- data/spec/tables_spec.rb +2 -3
- data/spec/text_field_spec.rb +51 -13
- data/spec/text_fields_spec.rb +2 -3
- data/spec/ul_spec.rb +18 -3
- data/spec/uls_spec.rb +2 -3
- data/spec/{watir_compatability_spec.rb → watir_compatibility_spec.rb} +42 -35
- data/support/spec_server.rb +9 -0
- metadata +167 -161
- metadata.gz.sig +0 -0
- data/benchmark/bm_2000_spans.rb +0 -48
- data/benchmark/bm_digg.rb +0 -26
- data/benchmark/bm_google_images.rb +0 -36
- data/benchmark/bm_input_locator.rb +0 -69
- data/benchmark/loader.rb +0 -9
- data/config/hoe.rb +0 -68
- data/config/requirements.rb +0 -15
- data/lib/celerity/htmlunit/htmlunit-2.2-SNAPSHOT.jar +0 -0
- data/lib/celerity/htmlunit/js-1.7R1.jar +0 -0
- data/lib/celerity/ie.rb +0 -195
- data/setup.rb +0 -1583
- data/support/celerity_viewer/rubycocoa/CelerityViewer.icns +0 -0
- data/support/celerity_viewer/rubycocoa/English.lproj/Main.nib/classes.nib +0 -37
- data/support/celerity_viewer/rubycocoa/English.lproj/Main.nib/info.nib +0 -19
- data/support/celerity_viewer/rubycocoa/English.lproj/Main.nib/keyedobjects.nib +0 -0
- data/support/celerity_viewer/rubycocoa/Info.plist.erb +0 -28
- data/support/celerity_viewer/rubycocoa/MainController.rb +0 -23
- data/support/celerity_viewer/rubycocoa/README +0 -94
- data/support/celerity_viewer/rubycocoa/Rakefile +0 -100
- data/support/celerity_viewer/rubycocoa/distributed_viewer.rb +0 -86
- data/support/celerity_viewer/rubycocoa/main.m +0 -7
- data/support/celerity_viewer/rubycocoa/main.rb +0 -27
- data/tasks/benchmark.rake +0 -4
- data/tasks/environment.rake +0 -7
- data/tasks/simple_ci.rake +0 -94
data/spec/hns_spec.rb
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
2
|
|
3
|
-
describe H1s, H2s, H3s, H4s, H5s, H6s do
|
3
|
+
describe "H1s", "H2s", "H3s", "H4s", "H5s", "H6s" do
|
4
4
|
|
5
5
|
before :all do
|
6
|
-
@browser =
|
7
|
-
add_spec_checker(@browser)
|
6
|
+
@browser = Browser.new
|
8
7
|
end
|
9
8
|
|
10
9
|
before :each do
|
@@ -13,23 +12,28 @@ describe H1s, H2s, H3s, H4s, H5s, H6s do
|
|
13
12
|
|
14
13
|
describe "#length" do
|
15
14
|
it "should return the number of h1s" do
|
16
|
-
@browser.h2s.length.should ==
|
15
|
+
@browser.h2s.length.should == 9
|
17
16
|
end
|
18
17
|
end
|
19
18
|
|
20
19
|
describe "#[]" do
|
21
|
-
it "should return the
|
20
|
+
it "should return the h1 at the given index" do
|
22
21
|
@browser.h1s[1].id.should == "first_header"
|
23
22
|
end
|
24
23
|
end
|
25
24
|
|
26
25
|
describe "#each" do
|
27
|
-
it "should iterate through
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
26
|
+
it "should iterate through header collections correctly" do
|
27
|
+
lengths = (1..6).collect do |i|
|
28
|
+
collection = @browser.send(:"h#{i}s")
|
29
|
+
collection.each_with_index do |h, index|
|
30
|
+
h.name.should == @browser.send(:"h#{i}", :index, index+1).name
|
31
|
+
h.id.should == @browser.send(:"h#{i}", :index, index+1).id
|
32
|
+
h.value.should == @browser.send(:"h#{i}", :index, index+1).value
|
33
|
+
end
|
34
|
+
collection.length
|
32
35
|
end
|
36
|
+
lengths.should == [2, 9, 2, 1, 1, 2]
|
33
37
|
end
|
34
38
|
end
|
35
39
|
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<html>
|
2
|
+
<head>
|
3
|
+
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
4
|
+
<title>form javascript bug</title>
|
5
|
+
|
6
|
+
</head>
|
7
|
+
<form action="post_to_me" method="post" accept-charset="utf-8">
|
8
|
+
<input type="text" name="some_name" value="" id="some_name">
|
9
|
+
<p><input type="submit" value="Continue →" id="submit_button" onclick="javascript:;"></p>
|
10
|
+
</form>
|
11
|
+
</html>
|
@@ -25,7 +25,7 @@
|
|
25
25
|
<option value="5">USA</option>
|
26
26
|
</select> <br />
|
27
27
|
<label for="new_user_occupation">Occupation</label>
|
28
|
-
<input type="text" name="new_user_occupation" id="new_user_occupation" value="Developer" /> <br />
|
28
|
+
<input type="text" name="new_user_occupation" id="new_user_occupation" value="Developer" onfocus="document.getElementById('onfocus_test').innerHTML = 'changed by onfocus event'"/> <br />
|
29
29
|
<label for="new_user_species">Species</label>
|
30
30
|
<input type="text" name="new_user_species" id="new_user_species" value="Homo sapiens sapiens" disabled="disabled" /> <br />
|
31
31
|
<label for="new_user_code">Personal code</label>
|
@@ -108,6 +108,7 @@
|
|
108
108
|
<!-- used for testing javascript events -->
|
109
109
|
<div id="changed_language"></div>
|
110
110
|
<div id="wants_newsletter"></div>
|
111
|
+
<div id="onfocus_test"></div>
|
111
112
|
|
112
113
|
</body>
|
113
114
|
</html>
|
data/spec/html/latin1_text.html
CHANGED
@@ -20,7 +20,7 @@
|
|
20
20
|
</ul>
|
21
21
|
</div>
|
22
22
|
<div id="promo" name="invalid_attribute" value="invalid_attribute">
|
23
|
-
<h2>Promo</h2>
|
23
|
+
<h2 id="promo_header">Promo</h2>
|
24
24
|
<span id="lead" class="lead" title="Lorem ipsum">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Curabitur eu pede. Ut justo. Praesent feugiat, elit in feugiat iaculis, sem risus rutrum justo, eget fermentum dolor arcu non nunc.</span>
|
25
25
|
<span name="invalid_attribute" value="invalid_attribute">Sed pretium metus et quam. Nullam odio dolor, vestibulum non, tempor ut, vehicula sed, sapien. Vestibulum placerat ligula at quam. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</span>
|
26
26
|
<span>Suspendisse at ipsum a turpis viverra venenatis. Praesent ut nibh. Nullam eu odio. Donec tempor, elit ut lacinia porttitor, augue neque vehicula diam, in elementum ligula nisi a tellus. Aliquam vestibulum ultricies tortor. </span>
|
@@ -99,9 +99,13 @@
|
|
99
99
|
</pre>
|
100
100
|
</div>
|
101
101
|
<div id="html_test" class=some_class title = "This is a title">
|
102
|
-
<h1>
|
103
|
-
|
104
|
-
<
|
102
|
+
<h1 id="header1">Header 1</h1>
|
103
|
+
<h2 id="header2">Header 2</h2>
|
104
|
+
<h3 id="header3">Header 3</h3>
|
105
|
+
<h4 id="header4">Header 4</h4>
|
106
|
+
<h5 id="header5">Header 5</h5>
|
107
|
+
<h6 id="header6">Header 6</h6>
|
108
|
+
<h6 id="empty_header"></h6>
|
105
109
|
</div>
|
106
110
|
<div id="footer" title="Closing remarks" class="profile">
|
107
111
|
<span class="footer" name="footer" onclick="this.innerHTML = 'This is a footer with text set by Javascript.'">This is a footer.</span>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<html><head><title>Simple Ajax</title><body>
|
2
|
+
<script type="text/javascript">
|
3
|
+
function doIt () {
|
4
|
+
var http = false;
|
5
|
+
|
6
|
+
if(navigator.appName == "Microsoft Internet Explorer") {
|
7
|
+
http = new ActiveXObject("Microsoft.XMLHTTP");
|
8
|
+
} else {
|
9
|
+
http = new XMLHttpRequest();
|
10
|
+
}
|
11
|
+
|
12
|
+
http.open("GET", "ajax");
|
13
|
+
http.onreadystatechange=function() {
|
14
|
+
if(http.readyState == 4) {
|
15
|
+
document.write(http.responseText);
|
16
|
+
}
|
17
|
+
}
|
18
|
+
http.send(null);
|
19
|
+
}
|
20
|
+
</script>
|
21
|
+
<a href='javascript:doIt()'>Click me</a>
|
22
|
+
</body></html>
|
data/spec/htmlunit_spec.rb
CHANGED
@@ -3,14 +3,13 @@ require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
3
3
|
describe "HtmlUnit bugs" do
|
4
4
|
|
5
5
|
before :all do
|
6
|
-
@browser =
|
7
|
-
add_spec_checker(@browser)
|
6
|
+
@browser = Browser.new
|
8
7
|
end
|
9
8
|
|
10
9
|
describe "HtmlUnit bug 1968686: https://sourceforge.net/tracker/index.php?func=detail&aid=1968686&group_id=47038&atid=448266" do
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
it "should not raise NativeException: java.lang.StackOverflowError when going to a page where Javascripts prints a <body> tag inside another <body> tag" do
|
11
|
+
lambda { @browser.goto(TEST_HOST + "/bug_javascript_001.html") }.should_not raise_error(NativeException)
|
12
|
+
end
|
14
13
|
end
|
15
14
|
|
16
15
|
describe "HtmlUnit bug 1968708: https://sourceforge.net/tracker/index.php?func=detail&aid=1968708&group_id=47038&atid=448266" do
|
data/spec/image_spec.rb
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
2
|
|
3
|
-
describe Image do
|
3
|
+
describe "Image" do
|
4
4
|
|
5
5
|
before :all do
|
6
|
-
@browser =
|
7
|
-
add_spec_checker(@browser)
|
6
|
+
@browser = Browser.new
|
8
7
|
end
|
9
8
|
|
10
9
|
before :each do
|
@@ -24,9 +23,11 @@ describe Image do
|
|
24
23
|
@browser.image(:alt, /cir/).should exist
|
25
24
|
@browser.image(:title, 'Circle').should exist
|
26
25
|
end
|
26
|
+
|
27
27
|
it "should return true if the element exists (default how = :id)" do
|
28
28
|
@browser.image("images/circle.jpg").should exist
|
29
29
|
end
|
30
|
+
|
30
31
|
it "should return false when the image exists" do
|
31
32
|
@browser.image(:id, 'no_such_id').should_not exist
|
32
33
|
@browser.image(:id, /no_such_id/).should_not exist
|
@@ -39,9 +40,11 @@ describe Image do
|
|
39
40
|
@browser.image(:title, 'no_such_title').should_not exist
|
40
41
|
@browser.image(:title, /no_such_title/).should_not exist
|
41
42
|
end
|
43
|
+
|
42
44
|
it "should raise ArgumentError when 'what' argument is invalid" do
|
43
45
|
lambda { @browser.button(:id, 3.14).exists? }.should raise_error(ArgumentError)
|
44
46
|
end
|
47
|
+
|
45
48
|
it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
46
49
|
lambda { @browser.button(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
47
50
|
end
|
@@ -53,9 +56,11 @@ describe Image do
|
|
53
56
|
@browser.image(:name, 'square').alt.should == "square"
|
54
57
|
@browser.image(:name, 'circle').alt.should == 'circle'
|
55
58
|
end
|
59
|
+
|
56
60
|
it "should return an empty string if the image exists and the attribute doesn't" do
|
57
61
|
@browser.image(:index, 1).alt.should == ""
|
58
62
|
end
|
63
|
+
|
59
64
|
it "should raise UnknownObjectException if the image doesn't exist" do
|
60
65
|
lambda { @browser.image(:index, 1337).alt }.should raise_error(UnknownObjectException)
|
61
66
|
end
|
@@ -65,9 +70,11 @@ describe Image do
|
|
65
70
|
it "should return the id attribute of the image if the image exists" do
|
66
71
|
@browser.image(:name, 'square').id.should == 'square'
|
67
72
|
end
|
73
|
+
|
68
74
|
it "should return an empty string if the image exists and the attribute doesn't" do
|
69
75
|
@browser.image(:index, 1).id.should == ""
|
70
76
|
end
|
77
|
+
|
71
78
|
it "should raise UnknownObjectException if the image doesn't exist" do
|
72
79
|
lambda { @browser.image(:index, 1337).id }.should raise_error(UnknownObjectException)
|
73
80
|
end
|
@@ -77,9 +84,11 @@ describe Image do
|
|
77
84
|
it "should return the name attribute of the image if the image exists" do
|
78
85
|
@browser.image(:name, 'square').name.should == 'square'
|
79
86
|
end
|
87
|
+
|
80
88
|
it "should return an empty string if the image exists and the attribute doesn't" do
|
81
89
|
@browser.image(:index, 1).name.should == ""
|
82
90
|
end
|
91
|
+
|
83
92
|
it "should raise UnknownObjectException if the image doesn't exist" do
|
84
93
|
lambda { @browser.image(:index, 1337).name }.should raise_error(UnknownObjectException)
|
85
94
|
end
|
@@ -89,9 +98,11 @@ describe Image do
|
|
89
98
|
it "should return the src attribute of the image if the image exists" do
|
90
99
|
@browser.image(:name, 'square').src.should match(/square\.jpg/i)
|
91
100
|
end
|
101
|
+
|
92
102
|
it "should return an empty string if the image exists and the attribute doesn't" do
|
93
103
|
@browser.image(:index, 1).src.should == ""
|
94
104
|
end
|
105
|
+
|
95
106
|
it "should raise UnknownObjectException if the image doesn't exist" do
|
96
107
|
lambda { @browser.image(:index, 1337).src }.should raise_error(UnknownObjectException)
|
97
108
|
end
|
@@ -101,13 +112,27 @@ describe Image do
|
|
101
112
|
it "should return the title attribute of the image if the image exists" do
|
102
113
|
@browser.image(:id, 'square').title.should == 'Square'
|
103
114
|
end
|
115
|
+
|
104
116
|
it "should return an empty string if the image exists and the attribute doesn't" do
|
105
117
|
@browser.image(:index, 1).title.should == ""
|
106
118
|
end
|
119
|
+
|
107
120
|
it "should raise UnknownObjectException if the image doesn't exist" do
|
108
121
|
lambda { @browser.image(:index, 1337).title }.should raise_error(UnknownObjectException)
|
109
122
|
end
|
110
123
|
end
|
124
|
+
|
125
|
+
describe "#respond_to?" do
|
126
|
+
it "should return true for all attribute methods" do
|
127
|
+
@browser.image(:index, 1).should respond_to(:class_name)
|
128
|
+
@browser.image(:index, 1).should respond_to(:id)
|
129
|
+
@browser.image(:index, 1).should respond_to(:name)
|
130
|
+
@browser.image(:index, 1).should respond_to(:style)
|
131
|
+
@browser.image(:index, 1).should respond_to(:text)
|
132
|
+
@browser.image(:index, 1).should respond_to(:value)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
111
136
|
|
112
137
|
# Manipulation methods
|
113
138
|
describe "#click" do
|
@@ -132,6 +157,7 @@ describe Image do
|
|
132
157
|
it "should return the file size of the image if the image exists" do
|
133
158
|
@browser.image(:id, 'square').file_size.should == 788
|
134
159
|
end
|
160
|
+
|
135
161
|
it "should raise UnknownObjectException if the image doesn't exist" do
|
136
162
|
lambda { @browser.image(:index, 1337).file_size }.should raise_error(UnknownObjectException)
|
137
163
|
end
|
@@ -141,6 +167,7 @@ describe Image do
|
|
141
167
|
it "should return the height of the image if the image exists" do
|
142
168
|
@browser.image(:id, 'square').height.should == 88
|
143
169
|
end
|
170
|
+
|
144
171
|
it "should raise UnknownObjectException if the image doesn't exist" do
|
145
172
|
lambda { @browser.image(:index, 1337).height }.should raise_error(UnknownObjectException)
|
146
173
|
end
|
@@ -150,6 +177,7 @@ describe Image do
|
|
150
177
|
it "should return the width of the image if the image exists" do
|
151
178
|
@browser.image(:id, 'square').width.should == 88
|
152
179
|
end
|
180
|
+
|
153
181
|
it "should raise UnknownObjectException if the image doesn't exist" do
|
154
182
|
lambda { @browser.image(:index, 1337).width }.should raise_error(UnknownObjectException)
|
155
183
|
end
|
@@ -162,9 +190,11 @@ describe Image do
|
|
162
190
|
@browser.image(:alt, 'circle').should be_loaded
|
163
191
|
@browser.image(:alt, /circle/).should be_loaded
|
164
192
|
end
|
193
|
+
|
165
194
|
it "should return false if the image has not been loaded" do
|
166
195
|
@browser.image(:id, 'no_such_file').should_not be_loaded
|
167
196
|
end
|
197
|
+
|
168
198
|
it "should raise UnknownObjectException if the image doesn't exist" do
|
169
199
|
lambda { @browser.image(:name, 'no_such_image').loaded? }.should raise_error(UnknownObjectException)
|
170
200
|
lambda { @browser.image(:id, 'no_such_image').loaded? }.should raise_error(UnknownObjectException)
|
data/spec/images_spec.rb
CHANGED
data/spec/label_spec.rb
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
2
|
|
3
|
-
describe Label do
|
3
|
+
describe "Label" do
|
4
4
|
|
5
5
|
before :all do
|
6
|
-
@browser =
|
7
|
-
add_spec_checker(@browser)
|
6
|
+
@browser = Browser.new
|
8
7
|
end
|
9
8
|
|
10
9
|
before :each do
|
@@ -21,9 +20,11 @@ describe Label do
|
|
21
20
|
@browser.label(:index, 1).should exist
|
22
21
|
@browser.label(:xpath, "//label[@id='first_label']").should exist
|
23
22
|
end
|
23
|
+
|
24
24
|
it "should return true if the element exists (default how = :text)" do
|
25
25
|
@browser.label("First name").should exist
|
26
26
|
end
|
27
|
+
|
27
28
|
it "should return false if the element does not exist" do
|
28
29
|
@browser.label(:id, 'no_such_id').should_not exist
|
29
30
|
@browser.label(:id, /no_such_id/).should_not exist
|
@@ -32,9 +33,11 @@ describe Label do
|
|
32
33
|
@browser.label(:index, 1337).should_not exist
|
33
34
|
@browser.label(:xpath, "//input[@id='no_such_id']").should_not exist
|
34
35
|
end
|
36
|
+
|
35
37
|
it "should raise ArgumentError when 'what' argument is invalid" do
|
36
38
|
lambda { @browser.label(:id, 3.14).exists? }.should raise_error(ArgumentError)
|
37
39
|
end
|
40
|
+
|
38
41
|
it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
39
42
|
lambda { @browser.label(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
40
43
|
end
|
@@ -45,6 +48,7 @@ describe Label do
|
|
45
48
|
it "should return the id attribute if the label exists" do
|
46
49
|
@browser.label(:index, 1).id.should == "first_label"
|
47
50
|
end
|
51
|
+
|
48
52
|
it "should raise UnknownObjectException if the label doesn't exist" do
|
49
53
|
lambda { @browser.label(:index, 1337).id }.should raise_error(UnknownObjectException)
|
50
54
|
end
|
@@ -54,10 +58,19 @@ describe Label do
|
|
54
58
|
it "should return the 'for' attribute if the label exists" do
|
55
59
|
@browser.label(:index, 1).for.should == "new_user_first_name"
|
56
60
|
end
|
61
|
+
|
57
62
|
it "should raise UnknownObjectException if the label doesn't exist" do
|
58
63
|
lambda { @browser.label(:index, 1337).for }.should raise_error(UnknownObjectException)
|
59
64
|
end
|
60
65
|
end
|
66
|
+
|
67
|
+
describe "#respond_to?" do
|
68
|
+
it "should return true for all attribute methods" do
|
69
|
+
@browser.label(:index, 1).should respond_to(:id)
|
70
|
+
@browser.label(:index, 1).should respond_to(:for)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
61
74
|
|
62
75
|
after :all do
|
63
76
|
@browser.close
|
data/spec/labels_spec.rb
CHANGED
data/spec/li_spec.rb
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
2
|
|
3
|
-
describe Li do
|
3
|
+
describe "Li" do
|
4
4
|
|
5
5
|
before :all do
|
6
|
-
@browser =
|
7
|
-
add_spec_checker(@browser)
|
6
|
+
@browser = Browser.new
|
8
7
|
end
|
9
8
|
|
10
9
|
before :each do
|
@@ -23,9 +22,11 @@ describe Li do
|
|
23
22
|
@browser.li(:index, 1).should exist
|
24
23
|
@browser.li(:xpath, "//li[@id='non_link_1']").should exist
|
25
24
|
end
|
25
|
+
|
26
26
|
it "should return true if the element exists (default how = :id)" do
|
27
27
|
@browser.li("non_link_1").should exist
|
28
28
|
end
|
29
|
+
|
29
30
|
it "should return false if the 'li' doesn't exist" do
|
30
31
|
@browser.li(:id, "no_such_id").should_not exist
|
31
32
|
@browser.li(:id, /no_such_id/).should_not exist
|
@@ -36,9 +37,11 @@ describe Li do
|
|
36
37
|
@browser.li(:index, 1337).should_not exist
|
37
38
|
@browser.li(:xpath, "//li[@id='no_such_id']").should_not exist
|
38
39
|
end
|
40
|
+
|
39
41
|
it "should raise ArgumentError when 'what' argument is invalid" do
|
40
42
|
lambda { @browser.li(:id, 3.14).exists? }.should raise_error(ArgumentError)
|
41
43
|
end
|
44
|
+
|
42
45
|
it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
43
46
|
lambda { @browser.li(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
44
47
|
end
|
@@ -49,9 +52,11 @@ describe Li do
|
|
49
52
|
it "should return the class attribute" do
|
50
53
|
@browser.li(:id, 'non_link_1').class_name.should == 'nonlink'
|
51
54
|
end
|
55
|
+
|
52
56
|
it "should return an empty string if the element exists and the attribute doesn't" do
|
53
57
|
@browser.li(:index, 1).class_name.should == ''
|
54
58
|
end
|
59
|
+
|
55
60
|
it "should raise UnknownObjectException if the li doesn't exist" do
|
56
61
|
lambda { @browser.li(:id, 'no_such_id').class_name }.should raise_error(UnknownObjectException)
|
57
62
|
end
|
@@ -61,9 +66,11 @@ describe Li do
|
|
61
66
|
it "should return the id attribute" do
|
62
67
|
@browser.li(:class, 'nonlink').id.should == "non_link_1"
|
63
68
|
end
|
69
|
+
|
64
70
|
it "should return an empty string if the element exists and the attribute doesn't" do
|
65
71
|
@browser.li(:index, 1).id.should == ''
|
66
72
|
end
|
73
|
+
|
67
74
|
it "should raise UnknownObjectException if the li doesn't exist" do
|
68
75
|
lambda { @browser.li(:id, "no_such_id").id }.should raise_error(UnknownObjectException)
|
69
76
|
lambda { @browser.li(:index, 1337).id }.should raise_error(UnknownObjectException)
|
@@ -74,9 +81,11 @@ describe Li do
|
|
74
81
|
it "should return the title attribute" do
|
75
82
|
@browser.li(:id, 'non_link_1').title.should == 'This is not a link!'
|
76
83
|
end
|
84
|
+
|
77
85
|
it "should return an empty string if the element exists and the attribute doesn't" do
|
78
86
|
@browser.li(:index, 1).title.should == ''
|
79
87
|
end
|
88
|
+
|
80
89
|
it "should raise UnknownObjectException if the li doesn't exist" do
|
81
90
|
lambda { @browser.li(:id, 'no_such_id').title }.should raise_error( UnknownObjectException)
|
82
91
|
lambda { @browser.li(:xpath, "//li[@id='no_such_id']").title }.should raise_error( UnknownObjectException)
|
@@ -87,14 +96,26 @@ describe Li do
|
|
87
96
|
it "should return the text of the p" do
|
88
97
|
@browser.li(:id, 'non_link_1').text.should == 'Non-link 1'
|
89
98
|
end
|
99
|
+
|
90
100
|
it "should return an empty string if the element doesn't contain any text" do
|
91
101
|
@browser.li(:index, 1).text.should == ''
|
92
102
|
end
|
103
|
+
|
93
104
|
it "should raise UnknownObjectException if the li doesn't exist" do
|
94
105
|
lambda { @browser.li(:id, 'no_such_id').text }.should raise_error( UnknownObjectException)
|
95
106
|
lambda { @browser.li(:xpath , "//li[@id='no_such_id']").text }.should raise_error( UnknownObjectException)
|
96
107
|
end
|
97
108
|
end
|
109
|
+
|
110
|
+
describe "#respond_to?" do
|
111
|
+
it "should return true for all attribute methods" do
|
112
|
+
@browser.li(:index, 1).should respond_to(:class_name)
|
113
|
+
@browser.li(:index, 1).should respond_to(:id)
|
114
|
+
@browser.li(:index, 1).should respond_to(:text)
|
115
|
+
@browser.li(:index, 1).should respond_to(:title)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
98
119
|
|
99
120
|
# Other
|
100
121
|
describe "#to_s" do
|
@@ -105,6 +126,7 @@ describe Li do
|
|
105
126
|
" title: This is not a link!\n" +
|
106
127
|
" text: Non-link 1"
|
107
128
|
end
|
129
|
+
|
108
130
|
it "should raise UnknownObjectException if the li doesn't exist" do
|
109
131
|
lambda { @browser.li(:xpath, "//li[@id='no_such_id']").to_s }.should raise_error( UnknownObjectException)
|
110
132
|
end
|