celerity 0.0.4 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +33 -0
- data/README.txt +19 -9
- data/Rakefile +9 -3
- data/lib/celerity.rb +39 -39
- data/lib/celerity/browser.rb +538 -153
- data/lib/celerity/clickable_element.rb +48 -7
- data/lib/celerity/collections.rb +155 -131
- data/lib/celerity/container.rb +766 -385
- data/lib/celerity/default_viewer.rb +10 -0
- data/lib/celerity/disabled_element.rb +19 -2
- data/lib/celerity/element.rb +152 -83
- data/lib/celerity/element_collection.rb +106 -0
- data/lib/celerity/element_locator.rb +89 -66
- data/lib/celerity/elements/button.rb +23 -13
- data/lib/celerity/elements/file_field.rb +17 -5
- data/lib/celerity/elements/form.rb +21 -16
- data/lib/celerity/elements/frame.rb +75 -53
- data/lib/celerity/elements/image.rb +76 -63
- data/lib/celerity/elements/label.rb +4 -2
- data/lib/celerity/elements/link.rb +30 -18
- data/lib/celerity/elements/meta.rb +6 -0
- data/lib/celerity/{non_control_elements.rb → elements/non_control_elements.rb} +106 -76
- data/lib/celerity/elements/option.rb +16 -2
- data/lib/celerity/elements/radio_check.rb +55 -20
- data/lib/celerity/elements/select_list.rb +65 -29
- data/lib/celerity/elements/table.rb +141 -94
- data/lib/celerity/elements/table_cell.rb +13 -6
- data/lib/celerity/elements/{table_body.rb → table_elements.rb} +20 -8
- data/lib/celerity/elements/table_row.rb +23 -7
- data/lib/celerity/elements/text_field.rb +89 -33
- data/lib/celerity/exception.rb +77 -41
- data/lib/celerity/extra/method_generator.rb +42 -24
- data/lib/celerity/htmlunit.rb +49 -0
- data/lib/celerity/htmlunit/commons-collections-3.2.1.jar +0 -0
- data/lib/celerity/htmlunit/htmlunit-2.5-SNAPSHOT.jar +0 -0
- data/lib/celerity/htmlunit/htmlunit-core-js-2.5-SNAPSHOT.jar +0 -0
- data/lib/celerity/htmlunit/nekohtml-1.9.12-20090308.130127-11.jar +0 -0
- data/lib/celerity/htmlunit/serializer-2.7.1.jar +0 -0
- data/lib/celerity/htmlunit/xalan-2.7.1.jar +0 -0
- data/lib/celerity/htmlunit/xml-apis-1.3.04.jar +0 -0
- data/lib/celerity/identifier.rb +3 -2
- data/lib/celerity/input_element.rb +5 -5
- data/lib/celerity/listener.rb +135 -0
- data/lib/celerity/resources/no_viewer.png +0 -0
- data/lib/celerity/util.rb +88 -0
- data/lib/celerity/version.rb +4 -3
- data/lib/celerity/watir_compatibility.rb +35 -25
- data/tasks/jar.rake +57 -0
- metadata +35 -142
- data.tar.gz.sig +0 -0
- data/Manifest.txt +0 -150
- data/lib/celerity/element_collections.rb +0 -54
- data/lib/celerity/element_map.rb +0 -51
- data/lib/celerity/elements/table_footer.rb +0 -30
- data/lib/celerity/elements/table_header.rb +0 -30
- data/lib/celerity/htmlunit/commons-collections-3.2.jar +0 -0
- data/lib/celerity/htmlunit/download.sh +0 -23
- 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.8.jar +0 -0
- data/lib/celerity/htmlunit/xalan-2.7.0.jar +0 -0
- data/lib/celerity/htmlunit/xml-apis-1.0.b2.jar +0 -0
- data/spec/area_spec.rb +0 -97
- data/spec/areas_spec.rb +0 -40
- data/spec/browser_spec.rb +0 -266
- data/spec/button_spec.rb +0 -227
- data/spec/buttons_spec.rb +0 -39
- data/spec/checkbox_spec.rb +0 -302
- data/spec/checkboxes_spec.rb +0 -38
- data/spec/div_spec.rb +0 -207
- data/spec/divs_spec.rb +0 -39
- data/spec/element_spec.rb +0 -79
- data/spec/filefield_spec.rb +0 -123
- data/spec/filefields_spec.rb +0 -40
- data/spec/form_spec.rb +0 -59
- data/spec/forms_spec.rb +0 -41
- data/spec/frame_spec.rb +0 -121
- data/spec/frames_spec.rb +0 -71
- data/spec/hidden_spec.rb +0 -127
- data/spec/hiddens_spec.rb +0 -39
- data/spec/hn_spec.rb +0 -104
- data/spec/hns_spec.rb +0 -45
- data/spec/html/2000_spans.html +0 -2009
- data/spec/html/bug_duplicate_attributes.html +0 -14
- data/spec/html/bug_javascript_001.html +0 -11
- data/spec/html/form_js_bug.html +0 -11
- data/spec/html/forms_with_input_elements.html +0 -114
- data/spec/html/frame_1.html +0 -17
- data/spec/html/frame_2.html +0 -16
- data/spec/html/frames.html +0 -11
- data/spec/html/iframes.html +0 -12
- data/spec/html/images.html +0 -27
- 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/invalid_js.html +0 -11
- data/spec/html/latin1_text.html +0 -17
- data/spec/html/non_control_elements.html +0 -115
- data/spec/html/simple_ajax.html +0 -22
- data/spec/html/tables.html +0 -119
- data/spec/html/utf8_text.html +0 -15
- data/spec/htmlunit_spec.rb +0 -26
- data/spec/image_spec.rb +0 -220
- data/spec/images_spec.rb +0 -39
- data/spec/label_spec.rb +0 -79
- data/spec/labels_spec.rb +0 -40
- data/spec/li_spec.rb +0 -139
- data/spec/link_spec.rb +0 -189
- data/spec/links_spec.rb +0 -43
- data/spec/lis_spec.rb +0 -40
- data/spec/map_spec.rb +0 -102
- data/spec/maps_spec.rb +0 -40
- data/spec/meta_spec.rb +0 -8
- data/spec/ol_spec.rb +0 -87
- data/spec/ols_spec.rb +0 -40
- data/spec/option_spec.rb +0 -154
- data/spec/p_spec.rb +0 -171
- data/spec/pre_spec.rb +0 -135
- data/spec/pres_spec.rb +0 -40
- data/spec/ps_spec.rb +0 -40
- data/spec/radio_spec.rb +0 -299
- data/spec/radios_spec.rb +0 -42
- data/spec/select_list_spec.rb +0 -299
- data/spec/select_lists_spec.rb +0 -47
- data/spec/span_spec.rb +0 -184
- data/spec/spans_spec.rb +0 -64
- data/spec/spec.opts +0 -1
- data/spec/spec_helper.rb +0 -55
- data/spec/table_bodies_spec.rb +0 -57
- data/spec/table_body_spec.rb +0 -111
- data/spec/table_cell_spec.rb +0 -74
- data/spec/table_cells_spec.rb +0 -59
- data/spec/table_footer_spec.rb +0 -101
- data/spec/table_footers_spec.rb +0 -55
- data/spec/table_header_spec.rb +0 -101
- data/spec/table_headers_spec.rb +0 -55
- data/spec/table_row_spec.rb +0 -104
- data/spec/table_rows_spec.rb +0 -58
- data/spec/table_spec.rb +0 -160
- data/spec/tables_spec.rb +0 -42
- data/spec/text_field_spec.rb +0 -323
- data/spec/text_fields_spec.rb +0 -44
- data/spec/ul_spec.rb +0 -88
- data/spec/uls_spec.rb +0 -40
- data/spec/watir_compatibility_spec.rb +0 -260
- data/support/spec_server.rb +0 -73
- data/tasks/rspec.rake +0 -30
- data/tasks/specserver.rake +0 -21
- metadata.gz.sig +0 -0
data/spec/spans_spec.rb
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
-
|
3
|
-
describe "Spans" do
|
4
|
-
|
5
|
-
before :all do
|
6
|
-
@browser = Browser.new
|
7
|
-
end
|
8
|
-
|
9
|
-
before :each do
|
10
|
-
@browser.goto(TEST_HOST + "/non_control_elements.html")
|
11
|
-
end
|
12
|
-
|
13
|
-
describe "#length" do
|
14
|
-
it "should return the number of spans" do
|
15
|
-
@browser.spans.length.should == 6
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe "#[]" do
|
20
|
-
it "should return the p at the given index" do
|
21
|
-
@browser.spans[1].id.should == "lead"
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
describe "#each" do
|
26
|
-
it "should iterate through spans correctly" do
|
27
|
-
@browser.spans.each_with_index do |s, index|
|
28
|
-
s.name.should == @browser.span(:index, index+1).name
|
29
|
-
s.id.should == @browser.span(:index, index+1).id
|
30
|
-
s.value.should == @browser.span(:index, index+1).value
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
describe "#to_s" do
|
36
|
-
it "should return a human readable representation of the collection" do
|
37
|
-
@browser.spans.to_s.should == "tag: span\n" +
|
38
|
-
" id: lead\n" +
|
39
|
-
" class: lead\n" +
|
40
|
-
" title: Lorem ipsum\n" +
|
41
|
-
" text: 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.\n" +
|
42
|
-
"tag: span\n" +
|
43
|
-
" name: invalid_attribute\n" +
|
44
|
-
" value: invalid_attribute\n" +
|
45
|
-
" text: 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.\n" +
|
46
|
-
"tag: span\n" +
|
47
|
-
" text: 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. \n" +
|
48
|
-
"tag: span\n" +
|
49
|
-
" text: Dubito, ergo cogito, ergo sum.\n" +
|
50
|
-
"tag: span\n" +
|
51
|
-
"tag: span\n" +
|
52
|
-
" class: footer\n" +
|
53
|
-
" name: footer\n" +
|
54
|
-
" onclick: this.innerHTML = 'This is a footer with text set by Javascript.'\n" +
|
55
|
-
" text: This is a footer."
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
after :all do
|
60
|
-
@browser.close
|
61
|
-
end
|
62
|
-
|
63
|
-
end
|
64
|
-
|
data/spec/spec.opts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
--colour
|
data/spec/spec_helper.rb
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
require "fileutils"
|
2
|
-
|
3
|
-
begin
|
4
|
-
require 'spec'
|
5
|
-
rescue LoadError
|
6
|
-
require 'rubygems'
|
7
|
-
gem 'rspec'
|
8
|
-
require 'spec'
|
9
|
-
end
|
10
|
-
|
11
|
-
# require "profile"
|
12
|
-
|
13
|
-
$:.unshift(File.dirname(__FILE__) + '/../lib')
|
14
|
-
|
15
|
-
if RUBY_PLATFORM =~ /java/
|
16
|
-
require 'celerity'
|
17
|
-
include Celerity
|
18
|
-
include Celerity::Exception
|
19
|
-
else
|
20
|
-
require 'watir'
|
21
|
-
include Watir
|
22
|
-
include Watir::Exception
|
23
|
-
end
|
24
|
-
|
25
|
-
# ============
|
26
|
-
# = Debugger =
|
27
|
-
# ============
|
28
|
-
|
29
|
-
if ENV['DEBUGGER']
|
30
|
-
require "ruby-debug"
|
31
|
-
Debugger.start
|
32
|
-
Debugger.settings[:autoeval] = true
|
33
|
-
Debugger.settings[:autolist] = 1
|
34
|
-
end
|
35
|
-
|
36
|
-
# ===========
|
37
|
-
# = WEBrick =
|
38
|
-
# ===========
|
39
|
-
|
40
|
-
if RUBY_PLATFORM =~ /java/ || ENV['WATIR_SPEC']
|
41
|
-
unless defined? WEBRICK_SERVER
|
42
|
-
# cleaner way to do this?
|
43
|
-
require File.dirname(__FILE__) + "/../support/spec_server"
|
44
|
-
s = Celerity::SpecServer.new
|
45
|
-
begin
|
46
|
-
s.run
|
47
|
-
rescue Errno::EADDRINUSE
|
48
|
-
end
|
49
|
-
TEST_HOST = s.host
|
50
|
-
end
|
51
|
-
# TEST_HOST = "file://#{File.dirname(__FILE__)}/html"
|
52
|
-
else
|
53
|
-
puts "Remember to run \"rake specserver\" before running these tests!"
|
54
|
-
TEST_HOST = "http://localhost:2000"
|
55
|
-
end
|
data/spec/table_bodies_spec.rb
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
-
|
3
|
-
describe "TableBodies" do
|
4
|
-
|
5
|
-
before :all do
|
6
|
-
@browser = Browser.new
|
7
|
-
end
|
8
|
-
|
9
|
-
before :each do
|
10
|
-
@browser = Browser.new
|
11
|
-
@browser.goto(TEST_HOST + "/tables.html")
|
12
|
-
end
|
13
|
-
|
14
|
-
describe "#length" do
|
15
|
-
it "should return the correct number of table bodies (page context)" do
|
16
|
-
@browser.bodies.length.should == 5
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should return the correct number of table bodies (table context)" do
|
20
|
-
@browser.table(:index, 1).bodies.length.should == 2
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe "#[]" do
|
25
|
-
it "should return the row at the given index (page context)" do
|
26
|
-
@browser.bodies[1].id.should == "first"
|
27
|
-
@browser.bodies[2].name.should == "second"
|
28
|
-
end
|
29
|
-
|
30
|
-
it "should return the row at the given index (table context)" do
|
31
|
-
@browser.table(:index, 1).bodies[1].id.should == "first"
|
32
|
-
@browser.table(:index, 1).bodies[2].name.should == "second"
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
describe "#each" do
|
37
|
-
it "should iterate through table bodies correctly (table context)" do
|
38
|
-
@browser.bodies.each_with_index do |body, index|
|
39
|
-
body.name.should == @browser.tbody(:index, index+1).name
|
40
|
-
body.id.should == @browser.tbody(:index, index+1).id
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
it "should iterate through table bodies correctly (table context)" do
|
45
|
-
table = @browser.table(:index, 1)
|
46
|
-
table.bodies.each_with_index do |body, index|
|
47
|
-
body.name.should == table.body(:index, index+1).name
|
48
|
-
body.id.should == table.body(:index, index+1).id
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
after :all do
|
54
|
-
@browser.close
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|
data/spec/table_body_spec.rb
DELETED
@@ -1,111 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
-
|
3
|
-
describe "TableBody" do
|
4
|
-
|
5
|
-
before :all do
|
6
|
-
@browser = Browser.new
|
7
|
-
end
|
8
|
-
|
9
|
-
before :each do
|
10
|
-
@browser = Browser.new
|
11
|
-
@browser.goto(TEST_HOST + "/tables.html")
|
12
|
-
end
|
13
|
-
|
14
|
-
describe "#exists" do
|
15
|
-
it "should return true if the table body exists (page context)" do
|
16
|
-
@browser.body(:id, 'first').should exist
|
17
|
-
@browser.body(:id, /first/).should exist
|
18
|
-
@browser.body(:name, 'second').should exist
|
19
|
-
@browser.body(:name, /second/).should exist
|
20
|
-
@browser.body(:index, 1).should exist
|
21
|
-
@browser.body(:xpath, "//tbody[@id='first']").should exist
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should return true if the table body exists (table context)" do
|
25
|
-
@browser.table(:index, 1).body(:id, 'first').should exist
|
26
|
-
@browser.table(:index, 1).body(:id, /first/).should exist
|
27
|
-
@browser.table(:index, 1).body(:name, 'second').should exist
|
28
|
-
@browser.table(:index, 1).body(:name, /second/).should exist
|
29
|
-
@browser.table(:index, 1).body(:index, 1).should exist
|
30
|
-
@browser.table(:index, 1).body(:xpath, "//tbody[@id='first']").should exist
|
31
|
-
end
|
32
|
-
|
33
|
-
it "should return true if the element exists (default how = :id)" do
|
34
|
-
@browser.body("first").should exist
|
35
|
-
@browser.table(:index, 1).body("first").should exist
|
36
|
-
end
|
37
|
-
|
38
|
-
it "should return false if the table body exists (page context)" do
|
39
|
-
@browser.body(:id, 'no_such_id').should_not exist
|
40
|
-
@browser.body(:id, /no_such_id/).should_not exist
|
41
|
-
@browser.body(:name, 'no_such_name').should_not exist
|
42
|
-
@browser.body(:name, /no_such_name/).should_not exist
|
43
|
-
@browser.body(:index, 1337).should_not exist
|
44
|
-
@browser.body(:xpath, "//tbody[@id='no_such_id']").should_not exist
|
45
|
-
end
|
46
|
-
|
47
|
-
it "should return false if the table body exists (table context)" do
|
48
|
-
@browser.table(:index, 1).body(:id, 'no_such_id').should_not exist
|
49
|
-
@browser.table(:index, 1).body(:id, /no_such_id/).should_not exist
|
50
|
-
@browser.table(:index, 1).body(:name, 'no_such_name').should_not exist
|
51
|
-
@browser.table(:index, 1).body(:name, /no_such_name/).should_not exist
|
52
|
-
@browser.table(:index, 1).body(:index, 1337).should_not exist
|
53
|
-
@browser.table(:index, 1).body(:xpath, "//tbody[@id='no_such_id']").should_not exist
|
54
|
-
end
|
55
|
-
|
56
|
-
it "should raise ArgumentError when 'what' argument is invalid" do
|
57
|
-
lambda { @browser.body(:id, 3.14).exists? }.should raise_error(ArgumentError)
|
58
|
-
lambda { @browser.table(:index, 1).body(:id, 3.14).exists? }.should raise_error(ArgumentError)
|
59
|
-
end
|
60
|
-
|
61
|
-
it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
62
|
-
lambda { @browser.body(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
63
|
-
lambda { @browser.table(:index, 1).body(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
describe "#length" do
|
68
|
-
it "should return the correct number of table bodies (page context)" do
|
69
|
-
@browser.body(:id, 'first').length.should == 3
|
70
|
-
@browser.body(:name, 'second').length.should == 3
|
71
|
-
end
|
72
|
-
|
73
|
-
it "should return the correct number of table bodies (table context)" do
|
74
|
-
@browser.table(:index, 1).body(:id, 'first').length.should == 3
|
75
|
-
@browser.table(:index, 1).body(:name, 'second').length.should == 3
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
describe "#[]" do
|
80
|
-
it "should return the row at the given index (page context)" do
|
81
|
-
@browser.body(:id, 'first')[1].text.should == 'March 2008'
|
82
|
-
@browser.body(:id, 'first')[2][1].text.should == 'Gregory House'
|
83
|
-
@browser.body(:id, 'first')[3][1].text.should == 'Hugh Laurie'
|
84
|
-
end
|
85
|
-
|
86
|
-
it "should return the row at the given index (table context)" do
|
87
|
-
@browser.table(:index, 1).body(:id, 'first')[1].text.should == 'March 2008'
|
88
|
-
@browser.table(:index, 1).body(:id, 'first')[2][1].text.should == 'Gregory House'
|
89
|
-
@browser.table(:index, 1).body(:id, 'first')[3][1].text.should == 'Hugh Laurie'
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
describe "#each" do
|
94
|
-
it "should iterate through rows correctly" do
|
95
|
-
body = @browser.table(:index, 1).body(:id, 'first')
|
96
|
-
index = 1
|
97
|
-
body.each do |r|
|
98
|
-
r.name.should == @browser.row(:index, index).name
|
99
|
-
r.id.should == @browser.row(:index, index).id
|
100
|
-
r.value.should == @browser.row(:index, index).value
|
101
|
-
index += 1
|
102
|
-
end
|
103
|
-
index.should_not == 1
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
after :all do
|
108
|
-
@browser.close
|
109
|
-
end
|
110
|
-
|
111
|
-
end
|
data/spec/table_cell_spec.rb
DELETED
@@ -1,74 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
-
|
3
|
-
describe "TableCell" do
|
4
|
-
|
5
|
-
before :all do
|
6
|
-
@browser = Browser.new
|
7
|
-
end
|
8
|
-
|
9
|
-
before :each do
|
10
|
-
@browser = Browser.new
|
11
|
-
@browser.goto(TEST_HOST + "/tables.html")
|
12
|
-
end
|
13
|
-
|
14
|
-
# Exists
|
15
|
-
describe "#exists" do
|
16
|
-
it "should return true when the table cell exists" do
|
17
|
-
@browser.cell(:id, 't1_r2_c1').should exist
|
18
|
-
@browser.cell(:id, /t1_r2_c1/).should exist
|
19
|
-
@browser.cell(:text, 'Table 1, Row 3, Cell 1').should exist
|
20
|
-
@browser.cell(:text, /Table 1/).should exist
|
21
|
-
@browser.cell(:index, 1).should exist
|
22
|
-
@browser.cell(:xpath, "//td[@id='t1_r2_c1']").should exist
|
23
|
-
end
|
24
|
-
|
25
|
-
it "should return true if the element exists (default how = :id)" do
|
26
|
-
@browser.cell("t1_r2_c1").should exist
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should return false when the table cell does not exist" do
|
30
|
-
@browser.cell(:id, 'no_such_id').should_not exist
|
31
|
-
@browser.cell(:id, /no_such_id/).should_not exist
|
32
|
-
@browser.cell(:text, 'no_such_text').should_not exist
|
33
|
-
@browser.cell(:text, /no_such_text/).should_not exist
|
34
|
-
@browser.cell(:index, 1337).should_not exist
|
35
|
-
@browser.cell(:xpath, "//td[@id='no_such_id']").should_not exist
|
36
|
-
end
|
37
|
-
|
38
|
-
it "should raise ArgumentError when 'what' argument is invalid" do
|
39
|
-
lambda { @browser.cell(:id, 3.14).exists? }.should raise_error(ArgumentError)
|
40
|
-
end
|
41
|
-
|
42
|
-
it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
43
|
-
lambda { @browser.cell(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
# Attribute methods
|
48
|
-
describe "#text" do
|
49
|
-
it "should return the text inside the table cell" do
|
50
|
-
@browser.cell(:id, 't1_r2_c1').text.should == 'Table 1, Row 2, Cell 1'
|
51
|
-
@browser.cell(:id, 't2_r1_c1').text.should == 'Table 2, Row 1, Cell 1'
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
describe "#colspan" do
|
56
|
-
it "should get the colspan attribute" do
|
57
|
-
@browser.cell(:id, 'colspan_2').colspan.should == 2
|
58
|
-
@browser.cell(:id, 'no_colspan').colspan.should == 1
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
describe "#respond_to?" do
|
63
|
-
it "should return true for all attribute methods" do
|
64
|
-
@browser.cell(:index, 1).should respond_to(:text)
|
65
|
-
@browser.cell(:index, 1).should respond_to(:colspan)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
|
70
|
-
after :all do
|
71
|
-
@browser.close
|
72
|
-
end
|
73
|
-
|
74
|
-
end
|
data/spec/table_cells_spec.rb
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
-
|
3
|
-
describe "TableCells" do
|
4
|
-
|
5
|
-
before :all do
|
6
|
-
@browser = Browser.new
|
7
|
-
end
|
8
|
-
|
9
|
-
before :each do
|
10
|
-
@browser = Browser.new
|
11
|
-
@browser.goto(TEST_HOST + "/tables.html")
|
12
|
-
end
|
13
|
-
|
14
|
-
# describe "#length" do
|
15
|
-
# it "should return the number of cells" do
|
16
|
-
# @browser.table(:id, 'outer').cells.length.should == 6
|
17
|
-
# @browser.table(:id, 'inner').cells.length.should == 2
|
18
|
-
# end
|
19
|
-
# end
|
20
|
-
#
|
21
|
-
# describe "#[]" do
|
22
|
-
# it "should return the row at the given index" do
|
23
|
-
# @browser.table(:id, 'outer').cells[1].text.should == "Table 1, Row 1, Cell 1"
|
24
|
-
# @browser.table(:id, 'inner').cells[1].text.should == "Table 2, Row 1, Cell 1"
|
25
|
-
# @browser.table(:id, 'outer').cells[6].text.should == "Table 1, Row 3, Cell 2"
|
26
|
-
# end
|
27
|
-
# end
|
28
|
-
|
29
|
-
describe "#each" do
|
30
|
-
it "should iterate through cells correctly" do
|
31
|
-
# All cells on the page
|
32
|
-
@browser.cells.each_with_index do |c, index|
|
33
|
-
c.name.should == @browser.cell(:index, index+1).name
|
34
|
-
c.id.should == @browser.cell(:index, index+1).id
|
35
|
-
c.value.should == @browser.cell(:index, index+1).value
|
36
|
-
end
|
37
|
-
# Cells inside a table
|
38
|
-
inner_table = @browser.table(:id, 'inner')
|
39
|
-
inner_table.cells.each_with_index do |c, index|
|
40
|
-
c.name.should == inner_table.cell(:index, index+1).name
|
41
|
-
c.id.should == inner_table.cell(:index, index+1).id
|
42
|
-
c.value.should == inner_table.cell(:index, index+1).value
|
43
|
-
end
|
44
|
-
# Cells inside a table (should not include cells inside a table inside a table)
|
45
|
-
outer_table = @browser.table(:id, 'outer')
|
46
|
-
outer_table.cells.each_with_index do |c, index|
|
47
|
-
c.name.should == outer_table.cell(:index, index+1).name
|
48
|
-
c.id.should == outer_table.cell(:index, index+1).id
|
49
|
-
c.value.should == outer_table.cell(:index, index+1).value
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
after :all do
|
55
|
-
@browser.close
|
56
|
-
end
|
57
|
-
|
58
|
-
end
|
59
|
-
|
data/spec/table_footer_spec.rb
DELETED
@@ -1,101 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
-
|
3
|
-
describe "TableFooter" do
|
4
|
-
|
5
|
-
before :all do
|
6
|
-
@browser = Browser.new
|
7
|
-
end
|
8
|
-
|
9
|
-
before :each do
|
10
|
-
@browser = Browser.new
|
11
|
-
@browser.goto(TEST_HOST + "/tables.html")
|
12
|
-
end
|
13
|
-
|
14
|
-
describe "#exists" do
|
15
|
-
it "should return true if the table tfoot exists (page context)" do
|
16
|
-
@browser.tfoot(:id, 'tax_totals').should exist
|
17
|
-
@browser.tfoot(:id, /tax_totals/).should exist
|
18
|
-
@browser.tfoot(:index, 1).should exist
|
19
|
-
@browser.tfoot(:xpath, "//tfoot[@id='tax_totals']").should exist
|
20
|
-
end
|
21
|
-
|
22
|
-
it "should return true if the table tfoot exists (table context)" do
|
23
|
-
@browser.table(:index, 1).tfoot(:id, 'tax_totals').should exist
|
24
|
-
@browser.table(:index, 1).tfoot(:id, /tax_totals/).should exist
|
25
|
-
@browser.table(:index, 1).tfoot(:index, 1).should exist
|
26
|
-
@browser.table(:index, 1).tfoot(:xpath, "//tfoot[@id='tax_totals']").should exist
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should return true if the element exists (default how = :id)" do
|
30
|
-
@browser.tfoot("tax_totals").should exist
|
31
|
-
@browser.table(:index, 1).tfoot("tax_totals").should exist
|
32
|
-
end
|
33
|
-
|
34
|
-
it "should return false if the table tfoot exists (page context)" do
|
35
|
-
@browser.tfoot(:id, 'no_such_id').should_not exist
|
36
|
-
@browser.tfoot(:id, /no_such_id/).should_not exist
|
37
|
-
@browser.tfoot(:index, 1337).should_not exist
|
38
|
-
@browser.tfoot(:xpath, "//tfoot[@id='no_such_id']").should_not exist
|
39
|
-
end
|
40
|
-
|
41
|
-
it "should return false if the table tfoot exists (table context)" do
|
42
|
-
@browser.table(:index, 1).tfoot(:id, 'no_such_id').should_not exist
|
43
|
-
@browser.table(:index, 1).tfoot(:id, /no_such_id/).should_not exist
|
44
|
-
@browser.table(:index, 1).tfoot(:index, 1337).should_not exist
|
45
|
-
@browser.table(:index, 1).tfoot(:xpath, "//tfoot[@id='no_such_id']").should_not exist
|
46
|
-
end
|
47
|
-
|
48
|
-
it "should raise ArgumentError when 'what' argument is invalid" do
|
49
|
-
lambda { @browser.tfoot(:id, 3.14).exists? }.should raise_error(ArgumentError)
|
50
|
-
lambda { @browser.table(:index, 1).tfoot(:id, 3.14).exists? }.should raise_error(ArgumentError)
|
51
|
-
end
|
52
|
-
|
53
|
-
it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
54
|
-
lambda { @browser.tfoot(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
55
|
-
lambda { @browser.table(:index, 1).tfoot(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
describe "#length" do
|
60
|
-
it "should return the correct number of table bodies (page context)" do
|
61
|
-
@browser.tfoot(:id, 'tax_totals').length.should == 1
|
62
|
-
end
|
63
|
-
|
64
|
-
it "should return the correct number of table bodies (table context)" do
|
65
|
-
@browser.table(:index, 1).tfoot(:id, 'tax_totals').length.should == 1
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
describe "#[]" do
|
70
|
-
it "should return the row at the given index (page context)" do
|
71
|
-
@browser.tfoot(:id, 'tax_totals')[1].text.should == 'Sum 24 349 5 577 18 722'
|
72
|
-
@browser.tfoot(:id, 'tax_totals')[1][2].text.should == '24 349'
|
73
|
-
@browser.tfoot(:id, 'tax_totals')[1][3].text.should == '5 577'
|
74
|
-
end
|
75
|
-
|
76
|
-
it "should return the row at the given index (table context)" do
|
77
|
-
@browser.table(:index, 1).tfoot(:id, 'tax_totals')[1].text.should == 'Sum 24 349 5 577 18 722'
|
78
|
-
@browser.table(:index, 1).tfoot(:id, 'tax_totals')[1][2].text.should == '24 349'
|
79
|
-
@browser.table(:index, 1).tfoot(:id, 'tax_totals')[1][3].text.should == '5 577'
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
describe "#each" do
|
84
|
-
it "should iterate through rows correctly" do
|
85
|
-
tfoot = @browser.table(:index, 1).tfoot(:id, 'tax_totals')
|
86
|
-
index = 1
|
87
|
-
tfoot.each do |r|
|
88
|
-
r.name.should == @browser.row(:index, index).name
|
89
|
-
r.id.should == @browser.row(:index, index).id
|
90
|
-
r.value.should == @browser.row(:index, index).value
|
91
|
-
index += 1
|
92
|
-
end
|
93
|
-
index.should_not == 1
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
after :all do
|
98
|
-
@browser.close
|
99
|
-
end
|
100
|
-
|
101
|
-
end
|