watir-webdriver 0.0.9 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +9 -1
- data/Rakefile +2 -1
- data/VERSION +1 -1
- data/lib/watir-webdriver.rb +6 -7
- data/lib/watir-webdriver/attribute_helper.rb +17 -10
- data/lib/watir-webdriver/browser.rb +1 -1
- data/lib/watir-webdriver/cell_container.rb +19 -0
- data/lib/watir-webdriver/container.rb +8 -0
- data/lib/watir-webdriver/element_collection.rb +2 -2
- data/lib/watir-webdriver/elements/button.rb +3 -2
- data/lib/watir-webdriver/elements/element.rb +41 -1
- data/lib/watir-webdriver/elements/generated.rb +3 -3
- data/lib/watir-webdriver/elements/input.rb +0 -52
- data/lib/watir-webdriver/elements/select.rb +0 -1
- data/lib/watir-webdriver/elements/table.rb +26 -4
- data/lib/watir-webdriver/elements/table_cell.rb +36 -0
- data/lib/watir-webdriver/elements/table_row.rb +23 -14
- data/lib/watir-webdriver/elements/table_section.rb +9 -0
- data/lib/watir-webdriver/extensions/alerts.rb +69 -0
- data/lib/watir-webdriver/extensions/performance.rb +54 -0
- data/lib/watir-webdriver/locators/button_locator.rb +3 -5
- data/lib/watir-webdriver/locators/{table_row_locator.rb → child_cell_locator.rb} +11 -6
- data/lib/watir-webdriver/locators/child_row_locator.rb +37 -0
- data/lib/watir-webdriver/locators/element_locator.rb +24 -14
- data/lib/watir-webdriver/row_container.rb +19 -0
- data/lib/watir-webdriver/window_switching.rb +37 -10
- data/spec/alert_spec.rb +49 -0
- data/spec/element_locator_spec.rb +15 -16
- data/spec/element_spec.rb +0 -32
- data/spec/html/alerts.html +11 -0
- data/spec/input_spec.rb +8 -46
- data/spec/locator_spec_helper.rb +19 -5
- data/spec/spec_helper.rb +3 -0
- data/spec/watirspec/areas_spec.rb +8 -0
- data/spec/watirspec/browser_spec.rb +4 -4
- data/spec/watirspec/button_spec.rb +3 -4
- data/spec/watirspec/buttons_spec.rb +8 -0
- data/spec/watirspec/checkboxes_spec.rb +8 -0
- data/spec/watirspec/dds_spec.rb +8 -0
- data/spec/watirspec/dels_spec.rb +8 -0
- data/spec/watirspec/divs_spec.rb +8 -0
- data/spec/watirspec/dls_spec.rb +8 -0
- data/spec/watirspec/dts_spec.rb +8 -0
- data/spec/watirspec/element_spec.rb +71 -2
- data/spec/watirspec/ems_spec.rb +8 -0
- data/spec/watirspec/filefield_spec.rb +16 -11
- data/spec/watirspec/filefields_spec.rb +8 -0
- data/spec/watirspec/font_spec.rb +21 -19
- data/spec/watirspec/form_spec.rb +5 -3
- data/spec/watirspec/forms_spec.rb +11 -5
- data/spec/watirspec/frames_spec.rb +8 -0
- data/spec/watirspec/hiddens_spec.rb +8 -0
- data/spec/watirspec/hns_spec.rb +8 -0
- data/spec/watirspec/images_spec.rb +8 -0
- data/spec/watirspec/inses_spec.rb +8 -0
- data/spec/watirspec/label_spec.rb +2 -0
- data/spec/watirspec/labels_spec.rb +8 -0
- data/spec/watirspec/lib/server.rb +19 -1
- data/spec/watirspec/lib/spec_helper.rb +1 -1
- data/spec/watirspec/links_spec.rb +8 -0
- data/spec/watirspec/lis_spec.rb +8 -0
- data/spec/watirspec/maps_spec.rb +8 -0
- data/spec/watirspec/metas_spec.rb +8 -0
- data/spec/watirspec/ols_spec.rb +8 -0
- data/spec/watirspec/pres_spec.rb +8 -0
- data/spec/watirspec/ps_spec.rb +8 -0
- data/spec/watirspec/radios_spec.rb +8 -0
- data/spec/watirspec/select_list_spec.rb +6 -6
- data/spec/watirspec/select_lists_spec.rb +8 -0
- data/spec/watirspec/spans_spec.rb +8 -0
- data/spec/watirspec/strongs_spec.rb +8 -0
- data/spec/watirspec/table_nesting_spec.rb +50 -0
- data/spec/watirspec/table_spec.rb +62 -102
- data/spec/watirspec/tables_spec.rb +8 -0
- data/spec/watirspec/{table_body_spec.rb → tbody_spec.rb} +21 -31
- data/spec/watirspec/{table_bodies_spec.rb → tbodys_spec.rb} +8 -0
- data/spec/watirspec/td_spec.rb +72 -0
- data/spec/watirspec/{table_cells_spec.rb → tds_spec.rb} +18 -25
- data/spec/watirspec/text_fields_spec.rb +8 -0
- data/spec/watirspec/{table_footer_spec.rb → tfoot_spec.rb} +21 -28
- data/spec/watirspec/{table_footers_spec.rb → tfoots_spec.rb} +8 -0
- data/spec/watirspec/{table_header_spec.rb → thead_spec.rb} +21 -29
- data/spec/watirspec/{table_headers_spec.rb → theads_spec.rb} +8 -0
- data/spec/watirspec/tr_spec.rb +88 -0
- data/spec/watirspec/trs_spec.rb +68 -0
- data/spec/watirspec/uls_spec.rb +8 -0
- data/spec/watirspec/window_switching_spec.rb +165 -0
- data/support/html5.html +884 -422
- data/watir-webdriver.gemspec +91 -85
- metadata +159 -161
- data/Gemfile.lock +0 -48
- data/spec/html/closeable.html +0 -13
- data/spec/html/data_attributes.html +0 -9
- data/spec/html/window_switching.html +0 -12
- data/spec/watirspec/table_cell_spec.rb +0 -74
- data/spec/watirspec/table_row_spec.rb +0 -99
- data/spec/watirspec/table_rows_spec.rb +0 -60
- data/spec/window_switching_spec.rb +0 -116
@@ -7,6 +7,14 @@ describe "Tables" do
|
|
7
7
|
browser.goto(WatirSpec.files + "/tables.html")
|
8
8
|
end
|
9
9
|
|
10
|
+
bug "http://github.com/jarib/celerity/issues#issue/25", :celerity do
|
11
|
+
describe "with selectors" do
|
12
|
+
it "returns the matching elements" do
|
13
|
+
browser.tables(:rules => "groups").to_a.should == [browser.table(:rules => "groups")]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
10
18
|
describe "#length" do
|
11
19
|
it "returns the number of tables" do
|
12
20
|
browser.tables.length.should == 4
|
@@ -51,45 +51,35 @@ describe "TableBody" do
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
54
|
+
describe "#[]" do
|
55
|
+
it "returns the row at the given index (page context)" do
|
56
|
+
browser.tbody(:id, 'first')[0].text.should == 'March 2008'
|
57
|
+
browser.tbody(:id, 'first')[1][0].text.should == 'Gregory House'
|
58
|
+
browser.tbody(:id, 'first')[2][0].text.should == 'Hugh Laurie'
|
59
|
+
end
|
59
60
|
|
60
|
-
|
61
|
-
|
62
|
-
|
61
|
+
it "returns the row at the given index (table context)" do
|
62
|
+
browser.table(:index, 0).tbody(:id, 'first')[0].text.should == 'March 2008'
|
63
|
+
browser.table(:index, 0).tbody(:id, 'first')[1][0].text.should == 'Gregory House'
|
64
|
+
browser.table(:index, 0).tbody(:id, 'first')[2][0].text.should == 'Hugh Laurie'
|
63
65
|
end
|
64
66
|
end
|
65
67
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
browser.tbody(:id, 'first')[0].text.should == 'March 2008'
|
70
|
-
browser.tbody(:id, 'first')[1][0].text.should == 'Gregory House'
|
71
|
-
browser.tbody(:id, 'first')[2][0].text.should == 'Hugh Laurie'
|
72
|
-
end
|
73
|
-
|
74
|
-
it "returns the row at the given index (table context)" do
|
75
|
-
browser.table(:index, 0).tbody(:id, 'first')[0].text.should == 'March 2008'
|
76
|
-
browser.table(:index, 0).tbody(:id, 'first')[1][0].text.should == 'Gregory House'
|
77
|
-
browser.table(:index, 0).tbody(:id, 'first')[2][0].text.should == 'Hugh Laurie'
|
78
|
-
end
|
68
|
+
describe "#row" do
|
69
|
+
it "finds the first row matching the selector" do
|
70
|
+
pending
|
79
71
|
end
|
80
72
|
end
|
81
73
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
body = browser.table(:index, 0).tbody(:id, 'first')
|
86
|
-
expected_texts = ["march", "gregory", "hugh"]
|
87
|
-
|
88
|
-
body.each_with_index do |row, idx|
|
89
|
-
row.id.should == expected_texts[idx]
|
90
|
-
end
|
91
|
-
end
|
74
|
+
describe "#rows" do
|
75
|
+
it "finds rows matching the selector" do
|
76
|
+
pending
|
92
77
|
end
|
93
78
|
end
|
94
79
|
|
80
|
+
describe "#strings" do
|
81
|
+
it "returns the text of child cells" do
|
82
|
+
pending
|
83
|
+
end
|
84
|
+
end
|
95
85
|
end
|
@@ -7,6 +7,14 @@ describe "TableBodies" do
|
|
7
7
|
browser.goto(WatirSpec.files + "/tables.html")
|
8
8
|
end
|
9
9
|
|
10
|
+
bug "http://github.com/jarib/celerity/issues#issue/25", :celerity do
|
11
|
+
describe "with selectors" do
|
12
|
+
it "returns the matching elements" do
|
13
|
+
browser.tbodys(:id => "first").to_a.should == [browser.tbody(:id => "first")]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
10
18
|
describe "#length" do
|
11
19
|
it "returns the correct number of table bodies (page context)" do
|
12
20
|
browser.tbodys.length.should == 5
|
@@ -0,0 +1,72 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path('spec_helper', File.dirname(__FILE__))
|
3
|
+
|
4
|
+
describe "TableCell" do
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
browser.goto(WatirSpec.files + "/tables.html")
|
8
|
+
end
|
9
|
+
|
10
|
+
# Exists
|
11
|
+
describe "#exists?" do
|
12
|
+
it "returns true when the table cell exists" do
|
13
|
+
browser.td(:id, 't1_r2_c1').should exist
|
14
|
+
browser.td(:id, /t1_r2_c1/).should exist
|
15
|
+
browser.td(:text, 'Table 1, Row 3, Cell 1').should exist
|
16
|
+
browser.td(:text, /Table 1/).should exist
|
17
|
+
browser.td(:index, 0).should exist
|
18
|
+
browser.td(:xpath, "//td[@id='t1_r2_c1']").should exist
|
19
|
+
end
|
20
|
+
|
21
|
+
it "returns the first cell if given no args" do
|
22
|
+
browser.td.should exist
|
23
|
+
end
|
24
|
+
|
25
|
+
it "returns false when the table cell does not exist" do
|
26
|
+
browser.td(:id, 'no_such_id').should_not exist
|
27
|
+
browser.td(:id, /no_such_id/).should_not exist
|
28
|
+
browser.td(:text, 'no_such_text').should_not exist
|
29
|
+
browser.td(:text, /no_such_text/).should_not exist
|
30
|
+
browser.td(:index, 1337).should_not exist
|
31
|
+
browser.td(:xpath, "//td[@id='no_such_id']").should_not exist
|
32
|
+
end
|
33
|
+
|
34
|
+
it "raises TypeError when 'what' argument is invalid" do
|
35
|
+
lambda { browser.td(:id, 3.14).exists? }.should raise_error(TypeError)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
39
|
+
lambda { browser.td(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "#click" do
|
44
|
+
it "fires the table's onclick event" do
|
45
|
+
browser.td(:id, 't2_r1_c1').click
|
46
|
+
messages.should include('td')
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# Attribute methods
|
51
|
+
describe "#text" do
|
52
|
+
it "returns the text inside the table cell" do
|
53
|
+
browser.td(:id, 't1_r2_c1').text.should == 'Table 1, Row 2, Cell 1'
|
54
|
+
browser.td(:id, 't2_r1_c1').text.should == 'Table 2, Row 1, Cell 1'
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe "#colspan" do
|
59
|
+
it "gets the colspan attribute" do
|
60
|
+
browser.td(:id, 'colspan_2').colspan.should == 2
|
61
|
+
browser.td(:id, 'no_colspan').colspan.should == 1
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe "#respond_to?" do
|
66
|
+
it "returns true for all attribute methods" do
|
67
|
+
browser.td(:index, 0).should respond_to(:text)
|
68
|
+
browser.td(:index, 0).should respond_to(:colspan)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
@@ -7,6 +7,14 @@ describe "TableCells" do
|
|
7
7
|
browser.goto(WatirSpec.files + "/tables.html")
|
8
8
|
end
|
9
9
|
|
10
|
+
bug "http://github.com/jarib/celerity/issues#issue/25", :celerity do
|
11
|
+
describe "with selectors" do
|
12
|
+
it "returns the matching elements" do
|
13
|
+
browser.tds(:headers => "before_tax").to_a.should == [browser.td(:headers => "before_tax")]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
10
18
|
# describe "#length" do
|
11
19
|
# it "returns the number of cells" do
|
12
20
|
# browser.table(:id, 'outer').cells.length.should == 6
|
@@ -23,45 +31,30 @@ describe "TableCells" do
|
|
23
31
|
# end
|
24
32
|
|
25
33
|
describe "#each" do
|
26
|
-
it "iterates through cells correctly" do
|
27
|
-
# All cells on the page
|
34
|
+
it "iterates through all cells on the page correctly" do
|
28
35
|
count = 0
|
29
36
|
|
30
|
-
browser.
|
31
|
-
c.id.should == browser.
|
32
|
-
c.value.should == browser.
|
37
|
+
browser.tds.each_with_index do |c, index|
|
38
|
+
c.id.should == browser.td(:index, index).id
|
39
|
+
c.value.should == browser.td(:index, index).value
|
33
40
|
|
34
41
|
count += 1
|
35
42
|
end
|
36
43
|
|
37
44
|
count.should > 0
|
45
|
+
end
|
38
46
|
|
39
|
-
|
47
|
+
it "iterates through cells inside a table" do
|
40
48
|
count = 0
|
41
49
|
|
42
50
|
inner_table = browser.table(:id, 'inner')
|
43
|
-
inner_table.
|
44
|
-
c.id.should == inner_table.
|
45
|
-
c.value.should == inner_table.
|
51
|
+
inner_table.tds.each_with_index do |c, index|
|
52
|
+
c.id.should == inner_table.td(:index, index).id
|
53
|
+
c.value.should == inner_table.td(:index, index).value
|
46
54
|
|
47
55
|
count += 1
|
48
56
|
end
|
49
|
-
|
50
|
-
count.should > 0
|
51
|
-
|
52
|
-
# Cells inside a table (should not include cells inside a table inside a table)
|
53
|
-
outer_table = browser.table(:id, 'outer')
|
54
|
-
count = 0
|
55
|
-
|
56
|
-
outer_table.cells.each_with_index do |c, index|
|
57
|
-
c.id.should == outer_table.cell(:index, index).id
|
58
|
-
c.value.should == outer_table.cell(:index, index).value
|
59
|
-
|
60
|
-
count += 1
|
61
|
-
end
|
62
|
-
|
63
|
-
count.should > 0
|
64
57
|
end
|
65
|
-
end
|
66
58
|
|
59
|
+
end
|
67
60
|
end
|
@@ -7,6 +7,14 @@ describe "TextFields" do
|
|
7
7
|
browser.goto(WatirSpec.files + "/forms_with_input_elements.html")
|
8
8
|
end
|
9
9
|
|
10
|
+
bug "http://github.com/jarib/celerity/issues#issue/25", :celerity do
|
11
|
+
describe "with selectors" do
|
12
|
+
it "returns the matching elements" do
|
13
|
+
browser.text_fields(:name => "new_user_email").to_a.should == [browser.text_field(:name => "new_user_email")]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
10
18
|
describe "#length" do
|
11
19
|
it "returns the number of text fields" do
|
12
20
|
browser.text_fields.length.should == 9
|
@@ -50,42 +50,35 @@ describe "TableFooter" do
|
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
53
|
+
describe "#[]" do
|
54
|
+
it "returns the row at the given index (page context)" do
|
55
|
+
browser.tfoot(:id, 'tax_totals')[0].id.should == 'tfoot_row_1'
|
56
|
+
browser.tfoot(:id, 'tax_totals')[0][1].text.should == '24 349'
|
57
|
+
browser.tfoot(:id, 'tax_totals')[0][2].text.should == '5 577'
|
58
|
+
end
|
58
59
|
|
59
|
-
|
60
|
-
|
61
|
-
|
60
|
+
it "returns the row at the given index (table context)" do
|
61
|
+
browser.table(:index, 0).tfoot(:id, 'tax_totals')[0].id.should == "tfoot_row_1"
|
62
|
+
browser.table(:index, 0).tfoot(:id, 'tax_totals')[0][1].text.should == '24 349'
|
63
|
+
browser.table(:index, 0).tfoot(:id, 'tax_totals')[0][2].text.should == '5 577'
|
62
64
|
end
|
63
65
|
end
|
64
66
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
browser.tfoot(:id, 'tax_totals')[0][2].text.should == '5 577'
|
71
|
-
end
|
67
|
+
describe "#row" do
|
68
|
+
it "finds the first row matching the selector" do
|
69
|
+
pending
|
70
|
+
end
|
71
|
+
end
|
72
72
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
browser.table(:index, 0).tfoot(:id, 'tax_totals')[0][2].text.should == '5 577'
|
77
|
-
end
|
73
|
+
describe "#rows" do
|
74
|
+
it "finds rows matching the selector" do
|
75
|
+
pending
|
78
76
|
end
|
79
77
|
end
|
80
78
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
tfoot = browser.table(:index, 0).tfoot(:id, 'tax_totals')
|
85
|
-
tfoot.each_with_index do |r, idx|
|
86
|
-
r.id.should == "tfoot_row_#{idx + 1}"
|
87
|
-
end
|
88
|
-
end
|
79
|
+
describe "#strings" do
|
80
|
+
it "returns the text of child cells" do
|
81
|
+
pending
|
89
82
|
end
|
90
83
|
end
|
91
84
|
|
@@ -6,6 +6,14 @@ describe "TableFooters" do
|
|
6
6
|
browser.goto(WatirSpec.files + "/tables.html")
|
7
7
|
end
|
8
8
|
|
9
|
+
bug "http://github.com/jarib/celerity/issues#issue/25", :celerity do
|
10
|
+
describe "with selectors" do
|
11
|
+
it "returns the matching elements" do
|
12
|
+
browser.tfoots(:id => "tax_totals").to_a.should == [browser.tfoot(:id => "tax_totals")]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
9
17
|
describe "#length" do
|
10
18
|
it "returns the correct number of table tfoots (page context)" do
|
11
19
|
browser.tfoots.length.should == 1
|
@@ -51,43 +51,35 @@ describe "TableHeader" do
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
54
|
+
describe "#[]" do
|
55
|
+
it "returns the row at the given index (page context)" do
|
56
|
+
browser.thead(:id, 'tax_headers')[0].id.should == 'thead_row_1'
|
57
|
+
browser.thead(:id, 'tax_headers')[0][1].text.should == 'Before income tax'
|
58
|
+
browser.thead(:id, 'tax_headers')[0][2].text.should == 'Income tax'
|
59
|
+
end
|
59
60
|
|
60
|
-
|
61
|
-
|
62
|
-
|
61
|
+
it "returns the row at the given index (table context)" do
|
62
|
+
browser.table(:index, 0).thead(:id, 'tax_headers')[0].id.should == 'thead_row_1'
|
63
|
+
browser.table(:index, 0).thead(:id, 'tax_headers')[0][1].text.should == 'Before income tax'
|
64
|
+
browser.table(:index, 0).thead(:id, 'tax_headers')[0][2].text.should == 'Income tax'
|
63
65
|
end
|
64
66
|
end
|
65
67
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
browser.thead(:id, 'tax_headers')[0][2].text.should == 'Income tax'
|
72
|
-
end
|
68
|
+
describe "#row" do
|
69
|
+
it "finds the first row matching the selector" do
|
70
|
+
pending
|
71
|
+
end
|
72
|
+
end
|
73
73
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
browser.table(:index, 0).thead(:id, 'tax_headers')[0][2].text.should == 'Income tax'
|
78
|
-
end
|
74
|
+
describe "#rows" do
|
75
|
+
it "finds rows matching the selector" do
|
76
|
+
pending
|
79
77
|
end
|
80
78
|
end
|
81
79
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
theader = browser.table(:index, 0).thead(:id, 'tax_headers')
|
86
|
-
theader.each_with_index do |r, index|
|
87
|
-
r.id.should == browser.row(:index, index).id
|
88
|
-
r.value.should == browser.row(:index, index).value
|
89
|
-
end
|
90
|
-
end
|
80
|
+
describe "#strings" do
|
81
|
+
it "returns the text of child cells" do
|
82
|
+
pending
|
91
83
|
end
|
92
84
|
end
|
93
85
|
|
@@ -6,6 +6,14 @@ describe "TableHeaders" do
|
|
6
6
|
browser.goto(WatirSpec.files + "/tables.html")
|
7
7
|
end
|
8
8
|
|
9
|
+
bug "http://github.com/jarib/celerity/issues#issue/25", :celerity do
|
10
|
+
describe "with selectors" do
|
11
|
+
it "returns the matching elements" do
|
12
|
+
browser.theads(:id => "tax_headers").to_a.should == [browser.thead(:id => "tax_headers")]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
9
17
|
describe "#length" do
|
10
18
|
it "returns the correct number of table theads (page context)" do
|
11
19
|
browser.theads.length.should == 1
|
@@ -0,0 +1,88 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path('spec_helper', File.dirname(__FILE__))
|
3
|
+
|
4
|
+
describe "TableRow" do
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
browser.goto(WatirSpec.files + "/tables.html")
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#exists?" do
|
11
|
+
it "returns true if the table row exists" do
|
12
|
+
browser.tr(:id, "outer_first").should exist
|
13
|
+
browser.tr(:id, /outer_first/).should exist
|
14
|
+
browser.tr(:index, 0).should exist
|
15
|
+
browser.tr(:xpath, "//tr[@id='outer_first']")
|
16
|
+
end
|
17
|
+
|
18
|
+
it "returns the first row if given no args" do
|
19
|
+
browser.tr.should exist
|
20
|
+
end
|
21
|
+
|
22
|
+
it "returns false if the table row doesn't exist" do
|
23
|
+
browser.tr(:id, "no_such_id").should_not exist
|
24
|
+
browser.tr(:id, /no_such_id/).should_not exist
|
25
|
+
browser.tr(:index, 1337).should_not exist
|
26
|
+
browser.tr(:xpath, "//tr[@id='no_such_id']")
|
27
|
+
end
|
28
|
+
|
29
|
+
it "raises TypeError when 'what' argument is invalid" do
|
30
|
+
lambda { browser.tr(:id, 3.14).exists? }.should raise_error(TypeError)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
34
|
+
lambda { browser.tr(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "#click" do
|
39
|
+
bug "http://github.com/jarib/watir-webdriver/issues/issue/32", [:webdriver, :ie] do
|
40
|
+
it "fires the rows's onclick event" do
|
41
|
+
browser.tr(:id, 'inner_first').click
|
42
|
+
messages.should include('tr')
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "#[]" do
|
48
|
+
let(:table) { browser.table(:id => 'outer') }
|
49
|
+
|
50
|
+
it "returns the nth cell of the row" do
|
51
|
+
table[0][0].text.should == "Table 1, Row 1, Cell 1"
|
52
|
+
table[2][0].text.should == "Table 1, Row 3, Cell 1"
|
53
|
+
end
|
54
|
+
|
55
|
+
not_compliant_on :webdriver do
|
56
|
+
it "raises UnknownCellException if the index is out of bounds" do
|
57
|
+
lambda { table.tr(:index, 0)[1337] }.should raise_error(UnknownCellException)
|
58
|
+
lambda { table[0][1337] }.should raise_error(UnknownCellException)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "#cells" do
|
64
|
+
let(:table) { browser.table(:id => 'outer') }
|
65
|
+
|
66
|
+
it "returns the correct number of cells" do
|
67
|
+
table[0].cells.length.should == 2
|
68
|
+
table[1].cells.length.should == 2
|
69
|
+
table[2].cells.length.should == 2
|
70
|
+
end
|
71
|
+
|
72
|
+
it "finds cells in the table" do
|
73
|
+
pending
|
74
|
+
end
|
75
|
+
|
76
|
+
it "does not find cells from nested tables" do
|
77
|
+
table[1].cell(:id => "t2_r1_c1").should_not exist
|
78
|
+
table[1].cell(:id => /t2_r1_c1/).should_not exist
|
79
|
+
end
|
80
|
+
|
81
|
+
it "iterates correctly through the cells of the row" do
|
82
|
+
browser.table(:id, 'outer').row(:index => 1).cells.each_with_index do |cell, idx|
|
83
|
+
cell.id.should == "t1_r2_c#{idx + 1}"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|