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
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
2
|
+
|
|
3
|
+
describe "TableBody" do
|
|
4
|
+
|
|
5
|
+
before :all do
|
|
6
|
+
@ie = IE.new
|
|
7
|
+
add_spec_checker(@ie)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
before :each do
|
|
11
|
+
@ie = IE.new
|
|
12
|
+
@ie.goto(TEST_HOST + "/tables.html")
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
describe "#exists" do
|
|
16
|
+
it "should return true if the table body exists" do
|
|
17
|
+
@ie.table(:index, 1).body(:id, 'first').should exist
|
|
18
|
+
@ie.table(:index, 1).body(:id, /first/).should exist
|
|
19
|
+
@ie.table(:index, 1).body(:name, 'second').should exist
|
|
20
|
+
@ie.table(:index, 1).body(:name, /second/).should exist
|
|
21
|
+
@ie.table(:index, 1).body(:index, 1).should exist
|
|
22
|
+
@ie.table(:index, 1).body(:xpath, "//tbody[@id='first']").should exist
|
|
23
|
+
end
|
|
24
|
+
it "should return false if the table body exists" do
|
|
25
|
+
@ie.table(:index, 1).body(:id, 'no_such_id').should_not exist
|
|
26
|
+
@ie.table(:index, 1).body(:id, /no_such_id/).should_not exist
|
|
27
|
+
@ie.table(:index, 1).body(:name, 'no_such_name').should_not exist
|
|
28
|
+
@ie.table(:index, 1).body(:name, /no_such_name/).should_not exist
|
|
29
|
+
@ie.table(:index, 1).body(:index, 1337).should_not exist
|
|
30
|
+
@ie.table(:index, 1).body(:xpath, "//tbody[@id='no_such_id']").should_not exist
|
|
31
|
+
end
|
|
32
|
+
it "should raise ArgumentError when what argument is invalid" do
|
|
33
|
+
lambda { @ie.table(:index, 1).body(:id, 3.14).exists? }.should raise_error(ArgumentError)
|
|
34
|
+
end
|
|
35
|
+
it "should raise MissingWayOfFindingObjectException when how argument is invalid" do
|
|
36
|
+
lambda { @ie.table(:index, 1).body(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
describe "#length" do
|
|
41
|
+
it "should return the correct number of table bodies" do
|
|
42
|
+
@ie.table(:index, 1).body(:id, 'first').length.should == 3
|
|
43
|
+
@ie.table(:index, 1).body(:name, 'second').length.should == 3
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
describe "#[]" do
|
|
48
|
+
it "should return the row at the given index" do
|
|
49
|
+
@ie.table(:index, 1).body(:id, 'first')[1].text.should == 'March 2008'
|
|
50
|
+
@ie.table(:index, 1).body(:id, 'first')[2][1].text.should == 'Gregory House'
|
|
51
|
+
@ie.table(:index, 1).body(:id, 'first')[3][1].text.should == 'Hugh Laurie'
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
describe "#each" do
|
|
56
|
+
it "should iterate through rows correctly" do
|
|
57
|
+
body = @ie.table(:index, 1).body(:id, 'first')
|
|
58
|
+
index = 1
|
|
59
|
+
body.each do |r|
|
|
60
|
+
r.name.should == body.row(:index, index).name
|
|
61
|
+
r.id.should == body.row(:index, index).id
|
|
62
|
+
r.value.should == body.row(:index, index).value
|
|
63
|
+
index += 1
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
after :all do
|
|
69
|
+
@ie.close
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
end
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
2
|
+
|
|
3
|
+
describe "TableCell" do
|
|
4
|
+
|
|
5
|
+
before :all do
|
|
6
|
+
@ie = IE.new
|
|
7
|
+
add_spec_checker(@ie)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
before :each do
|
|
11
|
+
@ie = IE.new
|
|
12
|
+
@ie.goto(TEST_HOST + "/tables.html")
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Exists
|
|
16
|
+
describe "#exists" do
|
|
17
|
+
it "should return true when the table cell exists" do
|
|
18
|
+
@ie.cell(:id, 't1_r2_c1').should exist
|
|
19
|
+
@ie.cell(:id, /t1_r2_c1/).should exist
|
|
20
|
+
@ie.cell(:text, 'Table 1, Row 3, Cell 1').should exist
|
|
21
|
+
@ie.cell(:text, /Table 1/).should exist
|
|
22
|
+
@ie.cell(:index, 1).should exist
|
|
23
|
+
@ie.cell(:xpath, "//td[@id='t1_r2_c1']").should exist
|
|
24
|
+
end
|
|
25
|
+
it "should return false when the table cell does not exist" do
|
|
26
|
+
@ie.cell(:id, 'no_such_id').should_not exist
|
|
27
|
+
@ie.cell(:id, /no_such_id/).should_not exist
|
|
28
|
+
@ie.cell(:text, 'no_such_text').should_not exist
|
|
29
|
+
@ie.cell(:text, /no_such_text/).should_not exist
|
|
30
|
+
@ie.cell(:index, 1337).should_not exist
|
|
31
|
+
@ie.cell(:xpath, "//td[@id='no_such_id']").should_not exist
|
|
32
|
+
end
|
|
33
|
+
it "should raise ArgumentError when what argument is invalid" do
|
|
34
|
+
lambda { @ie.cell(:id, 3.14).exists? }.should raise_error(ArgumentError)
|
|
35
|
+
end
|
|
36
|
+
it "should raise MissingWayOfFindingObjectException when how argument is invalid" do
|
|
37
|
+
lambda { @ie.cell(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Attribute methods
|
|
42
|
+
describe "#text" do
|
|
43
|
+
it "should return the text inside the table cell" do
|
|
44
|
+
@ie.cell(:id, 't1_r2_c1').text.should == 'Table 1, Row 2, Cell 1'
|
|
45
|
+
@ie.cell(:id, 't2_r1_c1').text.should == 'Table 2, Row 1, Cell 1'
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
describe "#colspan" do
|
|
50
|
+
it "should get the colspan attribute" do
|
|
51
|
+
@ie.cell(:id, 'colspan_2').colspan.should == 2
|
|
52
|
+
@ie.cell(:id, 'no_colspan').colspan.should == 1
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
after :all do
|
|
57
|
+
@ie.close
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
2
|
+
|
|
3
|
+
describe "TableCells" do
|
|
4
|
+
|
|
5
|
+
before :all do
|
|
6
|
+
@ie = IE.new
|
|
7
|
+
add_spec_checker(@ie)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
before :each do
|
|
11
|
+
@ie = IE.new
|
|
12
|
+
@ie.goto(TEST_HOST + "/tables.html")
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# describe "#length" do
|
|
16
|
+
# it "should return the number of cells" do
|
|
17
|
+
# @ie.table(:id, 'outer').cells.length.should == 6
|
|
18
|
+
# @ie.table(:id, 'inner').cells.length.should == 2
|
|
19
|
+
# end
|
|
20
|
+
# end
|
|
21
|
+
#
|
|
22
|
+
# describe "#[]" do
|
|
23
|
+
# it "should return the row at the given index" do
|
|
24
|
+
# @ie.table(:id, 'outer').cells[1].text.should == "Table 1, Row 1, Cell 1"
|
|
25
|
+
# @ie.table(:id, 'inner').cells[1].text.should == "Table 2, Row 1, Cell 1"
|
|
26
|
+
# @ie.table(:id, 'outer').cells[6].text.should == "Table 1, Row 3, Cell 2"
|
|
27
|
+
# end
|
|
28
|
+
# end
|
|
29
|
+
|
|
30
|
+
describe "#each" do
|
|
31
|
+
it "should iterate through cells correctly" do
|
|
32
|
+
# All cells on the page
|
|
33
|
+
@ie.cells.each_with_index do |c, index|
|
|
34
|
+
c.name.should == @ie.cell(:index, index+1).name
|
|
35
|
+
c.id.should == @ie.cell(:index, index+1).id
|
|
36
|
+
c.value.should == @ie.cell(:index, index+1).value
|
|
37
|
+
end
|
|
38
|
+
# Cells inside a table
|
|
39
|
+
inner_table = @ie.table(:id, 'inner')
|
|
40
|
+
inner_table.cells.each_with_index do |c, index|
|
|
41
|
+
c.name.should == inner_table.cell(:index, index+1).name
|
|
42
|
+
c.id.should == inner_table.cell(:index, index+1).id
|
|
43
|
+
c.value.should == inner_table.cell(:index, index+1).value
|
|
44
|
+
end
|
|
45
|
+
# Cells inside a table (should not include cells inside a table inside a table)
|
|
46
|
+
outer_table = @ie.table(:id, 'outer')
|
|
47
|
+
outer_table.cells.each_with_index do |c, index|
|
|
48
|
+
c.name.should == outer_table.cell(:index, index+1).name
|
|
49
|
+
c.id.should == outer_table.cell(:index, index+1).id
|
|
50
|
+
c.value.should == outer_table.cell(:index, index+1).value
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
after :all do
|
|
56
|
+
@ie.close
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
end
|
|
60
|
+
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
2
|
+
|
|
3
|
+
describe "TableRow" do
|
|
4
|
+
|
|
5
|
+
before :all do
|
|
6
|
+
@ie = IE.new
|
|
7
|
+
add_spec_checker(@ie)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
before :each do
|
|
11
|
+
@ie = IE.new
|
|
12
|
+
@ie.goto(TEST_HOST + "/tables.html")
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
describe "#column_count" do
|
|
16
|
+
it "should return the number of columns (cells) in the row" do
|
|
17
|
+
@ie.table(:id, 'outer').rows[1].column_count.should == 2
|
|
18
|
+
@ie.table(:id, 'outer')[2].column_count.should == 2
|
|
19
|
+
@ie.table(:id, 'colspan')[1].column_count.should == 1
|
|
20
|
+
@ie.table(:id, 'colspan').rows[2].column_count.should == 2
|
|
21
|
+
@ie.rows[1].column_count.should == 4
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
describe "#length" do
|
|
26
|
+
it "should return the number of rows" do
|
|
27
|
+
@ie.table(:id, 'outer').rows.length.should == 3
|
|
28
|
+
@ie.table(:id, 'inner').rows.length.should == 1
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
describe "#[]n" do
|
|
33
|
+
it "should " do
|
|
34
|
+
@ie.table(:id, 'outer').row(:index, 1)[1].text.should == "Table 1, Row 1, Cell 1"
|
|
35
|
+
@ie.table(:id, 'outer')[1][1].text.should == "Table 1, Row 1, Cell 1"
|
|
36
|
+
@ie.table(:id, 'outer')[3][1].text.should == "Table 1, Row 3, Cell 1"
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
describe "#each" do
|
|
41
|
+
it "should " do
|
|
42
|
+
index = 1
|
|
43
|
+
@ie.table(:id, 'outer')[2].each do |c|
|
|
44
|
+
case index
|
|
45
|
+
when 1
|
|
46
|
+
c.text.should == "Table 1, Row 2, Cell 1"
|
|
47
|
+
when 2
|
|
48
|
+
c.text.should == "Table 1, Row 2, Cell 2 Table 2, Row 1, Cell 1 Table 2, Row 1, Cell 2"
|
|
49
|
+
end
|
|
50
|
+
index += 1
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
after :all do
|
|
56
|
+
@ie.close
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
2
|
+
|
|
3
|
+
describe "TableRows" do
|
|
4
|
+
|
|
5
|
+
before :all do
|
|
6
|
+
@ie = IE.new
|
|
7
|
+
add_spec_checker(@ie)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
before :each do
|
|
11
|
+
@ie = IE.new
|
|
12
|
+
@ie.goto(TEST_HOST + "/tables.html")
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
describe "#length" do
|
|
16
|
+
it "should return the correct number of cells (table context)" do
|
|
17
|
+
@ie.table(:id, 'inner').rows.length.should == 1
|
|
18
|
+
@ie.table(:id, 'outer').rows.length.should == 3
|
|
19
|
+
end
|
|
20
|
+
it "should return the correct number of cells (page context)" do
|
|
21
|
+
@ie.rows.length.should == 14
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
describe "#[]" do
|
|
26
|
+
it "should return the row at the given index (table context)" do
|
|
27
|
+
@ie.table(:id, 'outer').rows[1].text.should == "Table 1, Row 1, Cell 1 Table 1, Row 1, Cell 2"
|
|
28
|
+
end
|
|
29
|
+
it "should return the row at the given index (page context)" do
|
|
30
|
+
@ie.rows[1].text.should == "Before income tax Income tax After income tax"
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
describe "#each" do
|
|
35
|
+
it "should iterate through rows correctly" do
|
|
36
|
+
# rows inside a table
|
|
37
|
+
inner_table = @ie.table(:id, 'inner')
|
|
38
|
+
inner_table.rows.each_with_index do |r, index|
|
|
39
|
+
r.name.should == inner_table.row(:index, index+1).name
|
|
40
|
+
r.id.should == inner_table.row(:index, index+1).id
|
|
41
|
+
r.value.should == inner_table.row(:index, index+1).value
|
|
42
|
+
end
|
|
43
|
+
# rows inside a table (should not include rows inside a table inside a table)
|
|
44
|
+
outer_table = @ie.table(:id, 'outer')
|
|
45
|
+
outer_table.rows.each_with_index do |r, index|
|
|
46
|
+
r.name.should == outer_table.row(:index, index+1).name
|
|
47
|
+
r.id.should == outer_table.row(:index, index+1).id
|
|
48
|
+
r.value.should == outer_table.row(:index, index+1).value
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
after :all do
|
|
54
|
+
@ie.close
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
end
|
data/spec/table_spec.rb
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
2
|
+
|
|
3
|
+
describe "Table" do
|
|
4
|
+
|
|
5
|
+
before :all do
|
|
6
|
+
@ie = IE.new
|
|
7
|
+
add_spec_checker(@ie)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
before :each do
|
|
11
|
+
@ie = IE.new
|
|
12
|
+
@ie.goto(TEST_HOST + "/tables.html")
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Exists
|
|
16
|
+
describe "#exists?" do
|
|
17
|
+
it "should return true if the table exists" do
|
|
18
|
+
@ie.table(:id, 'axis_example').should exist
|
|
19
|
+
@ie.table(:id, /axis_example/).should exist
|
|
20
|
+
@ie.table(:index, 1).should exist
|
|
21
|
+
@ie.table(:xpath, "//table[@id='axis_example']").should exist
|
|
22
|
+
end
|
|
23
|
+
it "should return false if the table does not exist" do
|
|
24
|
+
@ie.table(:id, 'no_such_id').should_not exist
|
|
25
|
+
@ie.table(:id, /no_such_id/).should_not exist
|
|
26
|
+
@ie.table(:index, 1337).should_not exist
|
|
27
|
+
@ie.table(:xpath, "//table[@id='no_such_id']").should_not exist
|
|
28
|
+
end
|
|
29
|
+
it "should raise ArgumentError when what argument is invalid" do
|
|
30
|
+
lambda { @ie.table(:id, 3.14).exists? }.should raise_error(ArgumentError)
|
|
31
|
+
end
|
|
32
|
+
it "should raise MissingWayOfFindingObjectException when how argument is invalid" do
|
|
33
|
+
lambda { @ie.table(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Other
|
|
38
|
+
describe "#to_a" do
|
|
39
|
+
it "should return a two-dimensional array representation of the table" do
|
|
40
|
+
@ie.table(:id, 'inner').to_a.should == [["Table 2, Row 1, Cell 1", "Table 2, Row 1, Cell 2"]]
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
describe "#row_count" do
|
|
45
|
+
it "should count the number of rows correctly" do
|
|
46
|
+
@ie.table(:id, 'inner').row_count.should == 1
|
|
47
|
+
@ie.table(:id, 'outer').row_count.should == 3
|
|
48
|
+
end
|
|
49
|
+
it "should raise an UnknownObjectException if the table doesn't exist" do
|
|
50
|
+
lambda { @ie.table(:id, 'no_such_id').row_count }.should raise_error(UnknownObjectException)
|
|
51
|
+
lambda { @ie.table(:index, 1337).row_count }.should raise_error(UnknownObjectException)
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
describe "#row_values" do
|
|
56
|
+
it "should get row values" do
|
|
57
|
+
@ie.table(:id, 'outer').row_values(1).should == ["Table 1, Row 1, Cell 1", "Table 1, Row 1, Cell 2"]
|
|
58
|
+
@ie.table(:id, 'inner').row_values(1).should == ["Table 2, Row 1, Cell 1", "Table 2, Row 1, Cell 2"]
|
|
59
|
+
@ie.table(:id, 'outer').row_values(3).should == ["Table 1, Row 3, Cell 1", "Table 1, Row 3, Cell 2"]
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
describe "#column_count" do
|
|
64
|
+
it "should count the number of columns correctly" do
|
|
65
|
+
@ie.table(:id, 'inner').column_count.should == 2
|
|
66
|
+
@ie.table(:id, 'outer').column_count.should == 2
|
|
67
|
+
end
|
|
68
|
+
it "should raise an UnknownObjectException if the table doesn't exist" do
|
|
69
|
+
lambda { @ie.table(:id, 'no_such_id').column_count }.should raise_error(UnknownObjectException)
|
|
70
|
+
lambda { @ie.table(:index, 1337).column_count }.should raise_error(UnknownObjectException)
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
describe "#column_values" do
|
|
75
|
+
it "should get column values" do
|
|
76
|
+
@ie.table(:id, 'inner').column_values(1).should == ["Table 2, Row 1, Cell 1"]
|
|
77
|
+
@ie.table(:id, 'outer').column_values(1).should == ["Table 1, Row 1, Cell 1", "Table 1, Row 2, Cell 1", "Table 1, Row 3, Cell 1"]
|
|
78
|
+
end
|
|
79
|
+
it "should raise UnknownCellException when trying to locate non-existing cell" do
|
|
80
|
+
lambda { @ie.table(:id, 'inner').column_values(1337) }.should raise_error(UnknownCellException)
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
describe "#[]" do
|
|
85
|
+
it "should return the row at the given index" do
|
|
86
|
+
@ie.table(:id, 'outer')[1].id.should == "outer_first"
|
|
87
|
+
@ie.table(:id, 'inner')[1].id.should == "inner_first"
|
|
88
|
+
@ie.table(:id, 'outer')[3].id.should == "outer_last"
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
describe "#each" do
|
|
93
|
+
it "should iterate through the table's rows" do
|
|
94
|
+
index = 1
|
|
95
|
+
@ie.table(:id, 'outer').each do |r|
|
|
96
|
+
case index
|
|
97
|
+
when 1
|
|
98
|
+
r.text.should == "Table 1, Row 1, Cell 1 Table 1, Row 1, Cell 2"
|
|
99
|
+
when 3
|
|
100
|
+
r.text.should == "Table 1, Row 3, Cell 1 Table 1, Row 3, Cell 2"
|
|
101
|
+
end
|
|
102
|
+
index += 1
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
after :all do
|
|
108
|
+
@ie.close
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
end
|
data/spec/tables_spec.rb
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
2
|
+
|
|
3
|
+
describe "Tables" 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 + "/tables.html")
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
describe "#length" do
|
|
14
|
+
it "should return the number of tables" do
|
|
15
|
+
@ie.tables.length.should == 4
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
describe "#[]" do
|
|
20
|
+
it "should return the p at the given index" do
|
|
21
|
+
@ie.tables[1].id.should == "axis_example"
|
|
22
|
+
@ie.tables[2].id.should == "outer"
|
|
23
|
+
@ie.tables[3].id.should == "inner"
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
describe "#each" do
|
|
28
|
+
it "should iterate through tables correctly" do
|
|
29
|
+
@ie.tables.each_with_index do |t, index|
|
|
30
|
+
t.name.should == @ie.table(:index, index+1).name
|
|
31
|
+
t.id.should == @ie.table(:index, index+1).id
|
|
32
|
+
t.value.should == @ie.table(:index, index+1).value
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
after :all do
|
|
38
|
+
@ie.close
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
end
|
|
42
|
+
|