watir-webdriver 0.0.1.dev6 → 0.0.1.dev7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. data/Rakefile +1 -2
  2. data/VERSION +1 -1
  3. data/lib/watir-webdriver.rb +1 -4
  4. data/lib/watir-webdriver/base_element.rb +14 -7
  5. data/lib/watir-webdriver/browser.rb +3 -1
  6. data/lib/watir-webdriver/elements/button.rb +1 -0
  7. data/lib/watir-webdriver/elements/form.rb +1 -1
  8. data/lib/watir-webdriver/elements/frame.rb +77 -0
  9. data/lib/watir-webdriver/elements/generated.rb +536 -536
  10. data/lib/watir-webdriver/elements/option.rb +3 -0
  11. data/lib/watir-webdriver/elements/table_row.rb +1 -0
  12. data/lib/watir-webdriver/elements/text_field.rb +5 -1
  13. data/lib/watir-webdriver/xpath_support.rb +0 -1
  14. data/spec/base_element_spec.rb +16 -0
  15. data/spec/html/keylogger.html +15 -0
  16. data/spec/watirspec/area_spec.rb +78 -0
  17. data/spec/watirspec/areas_spec.rb +31 -0
  18. data/spec/watirspec/browser_spec.rb +274 -0
  19. data/spec/watirspec/button_spec.rb +242 -0
  20. data/spec/watirspec/buttons_spec.rb +48 -0
  21. data/spec/watirspec/checkbox_spec.rb +272 -0
  22. data/spec/watirspec/checkboxes_spec.rb +32 -0
  23. data/spec/watirspec/dd_spec.rb +123 -0
  24. data/spec/watirspec/dds_spec.rb +31 -0
  25. data/spec/watirspec/div_spec.rb +211 -0
  26. data/spec/watirspec/divs_spec.rb +31 -0
  27. data/spec/watirspec/dl_spec.rb +123 -0
  28. data/spec/watirspec/dls_spec.rb +32 -0
  29. data/spec/watirspec/dt_spec.rb +123 -0
  30. data/spec/watirspec/dts_spec.rb +31 -0
  31. data/spec/watirspec/element_spec.rb +89 -0
  32. data/spec/watirspec/em_spec.rb +97 -0
  33. data/spec/watirspec/ems_spec.rb +32 -0
  34. data/spec/watirspec/filefield_spec.rb +119 -0
  35. data/spec/watirspec/filefields_spec.rb +32 -0
  36. data/spec/watirspec/font_spec.rb +26 -0
  37. data/spec/watirspec/form_spec.rb +63 -0
  38. data/spec/watirspec/forms_spec.rb +33 -0
  39. data/spec/watirspec/frame_spec.rb +135 -0
  40. data/spec/watirspec/frames_spec.rb +62 -0
  41. data/spec/watirspec/hidden_spec.rb +102 -0
  42. data/spec/watirspec/hiddens_spec.rb +32 -0
  43. data/spec/watirspec/hn_spec.rb +93 -0
  44. data/spec/watirspec/hns_spec.rb +38 -0
  45. data/spec/watirspec/image_spec.rb +207 -0
  46. data/spec/watirspec/images_spec.rb +31 -0
  47. data/spec/watirspec/label_spec.rb +75 -0
  48. data/spec/watirspec/labels_spec.rb +31 -0
  49. data/spec/watirspec/li_spec.rb +112 -0
  50. data/spec/watirspec/lib/guards.rb +59 -0
  51. data/spec/watirspec/lib/server.rb +136 -0
  52. data/spec/watirspec/lib/spec_helper.rb +79 -0
  53. data/spec/watirspec/lib/watirspec.rb +72 -0
  54. data/spec/watirspec/link_spec.rb +168 -0
  55. data/spec/watirspec/links_spec.rb +35 -0
  56. data/spec/watirspec/lis_spec.rb +31 -0
  57. data/spec/watirspec/map_spec.rb +76 -0
  58. data/spec/watirspec/maps_spec.rb +32 -0
  59. data/spec/watirspec/meta_spec.rb +22 -0
  60. data/spec/watirspec/metas_spec.rb +30 -0
  61. data/spec/watirspec/ol_spec.rb +78 -0
  62. data/spec/watirspec/ols_spec.rb +31 -0
  63. data/spec/watirspec/option_spec.rb +173 -0
  64. data/spec/watirspec/p_spec.rb +128 -0
  65. data/spec/watirspec/pre_spec.rb +112 -0
  66. data/spec/watirspec/pres_spec.rb +31 -0
  67. data/spec/watirspec/ps_spec.rb +31 -0
  68. data/spec/watirspec/radio_spec.rb +255 -0
  69. data/spec/watirspec/radios_spec.rb +32 -0
  70. data/spec/watirspec/select_list_spec.rb +318 -0
  71. data/spec/watirspec/select_lists_spec.rb +35 -0
  72. data/spec/watirspec/span_spec.rb +142 -0
  73. data/spec/watirspec/spans_spec.rb +31 -0
  74. data/spec/watirspec/spec_helper.rb +17 -0
  75. data/spec/watirspec/strong_spec.rb +89 -0
  76. data/spec/watirspec/strongs_spec.rb +32 -0
  77. data/spec/watirspec/table_bodies_spec.rb +45 -0
  78. data/spec/watirspec/table_body_spec.rb +98 -0
  79. data/spec/watirspec/table_cell_spec.rb +68 -0
  80. data/spec/watirspec/table_cells_spec.rb +47 -0
  81. data/spec/watirspec/table_footer_spec.rb +85 -0
  82. data/spec/watirspec/table_footers_spec.rb +47 -0
  83. data/spec/watirspec/table_header_spec.rb +85 -0
  84. data/spec/watirspec/table_headers_spec.rb +45 -0
  85. data/spec/watirspec/table_row_spec.rb +87 -0
  86. data/spec/watirspec/table_rows_spec.rb +50 -0
  87. data/spec/watirspec/table_spec.rb +160 -0
  88. data/spec/watirspec/tables_spec.rb +33 -0
  89. data/spec/watirspec/text_field_spec.rb +276 -0
  90. data/spec/watirspec/text_fields_spec.rb +35 -0
  91. data/spec/watirspec/ul_spec.rb +76 -0
  92. data/spec/watirspec/uls_spec.rb +33 -0
  93. data/support/html5/html5.idl +1 -1
  94. metadata +181 -21
@@ -0,0 +1,35 @@
1
+ # encoding: utf-8
2
+ require File.dirname(__FILE__) + '/spec_helper'
3
+
4
+ describe "SelectLists" do
5
+
6
+ before :each do
7
+ browser.goto(WatirSpec.files + "/forms_with_input_elements.html")
8
+ end
9
+
10
+ describe "#length" do
11
+ it "returns the correct number of select lists on the page" do
12
+ browser.select_lists.length.should == 4
13
+ end
14
+ end
15
+
16
+ describe "#[]" do
17
+ it "returns the correct item" do
18
+ browser.select_lists[0].value.should == "2"
19
+ browser.select_lists[0].name.should == "new_user_country"
20
+ browser.select_lists[0].should_not be_multiple
21
+ browser.select_lists[1].should be_multiple
22
+ end
23
+ end
24
+
25
+ describe "#each" do
26
+ it "iterates through the select lists correctly" do
27
+ browser.select_lists.each_with_index do |l, index|
28
+ browser.select_list(:index, index).name.should == l.name
29
+ browser.select_list(:index, index).id.should == l.id
30
+ browser.select_list(:index, index).value.should == l.value
31
+ end
32
+ end
33
+ end
34
+
35
+ end
@@ -0,0 +1,142 @@
1
+ # encoding: utf-8
2
+ require File.dirname(__FILE__) + '/spec_helper'
3
+
4
+ describe "Span" do
5
+
6
+ before :each do
7
+ browser.goto(WatirSpec.files + "/non_control_elements.html")
8
+ end
9
+
10
+ # Exists method
11
+ describe "#exist?" do
12
+ it "returns true if the 'span' exists" do
13
+ browser.span(:id, "lead").should exist
14
+ browser.span(:id, /lead/).should exist
15
+ browser.span(:text, "Dubito, ergo cogito, ergo sum.").should exist
16
+ browser.span(:text, /Dubito, ergo cogito, ergo sum/).should exist
17
+ browser.span(:class, "lead").should exist
18
+ browser.span(:class, /lead/).should exist
19
+ browser.span(:index, 0).should exist
20
+ browser.span(:xpath, "//span[@id='lead']").should exist
21
+ end
22
+
23
+ it "returns false if the element doesn't exist" do
24
+ browser.span(:id, "no_such_id").should_not exist
25
+ browser.span(:id, /no_such_id/).should_not exist
26
+ browser.span(:text, "no_such_text").should_not exist
27
+ browser.span(:text, /no_such_text/).should_not exist
28
+ browser.span(:class, "no_such_class").should_not exist
29
+ browser.span(:class, /no_such_class/).should_not exist
30
+ browser.span(:index, 1337).should_not exist
31
+ browser.span(:xpath, "//span[@id='no_such_id']").should_not exist
32
+ end
33
+
34
+ it "raises TypeError when 'what' argument is invalid" do
35
+ lambda { browser.span(:id, 3.14).exists? }.should raise_error(TypeError)
36
+ end
37
+
38
+ it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
39
+ lambda { browser.span(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
40
+ end
41
+ end
42
+
43
+ # Attribute methods
44
+ describe "#class_name" do
45
+ it "returns the class attribute" do
46
+ browser.span(:index, 0).class_name.should == 'lead'
47
+ end
48
+
49
+ it "returns an empty string if the element exists and the attribute doesn't" do
50
+ browser.span(:index, 2).class_name.should == ''
51
+ end
52
+
53
+ it "raises UnknownObjectException if the span doesn't exist" do
54
+ lambda { browser.span(:id, 'no_such_id').class_name }.should raise_error(UnknownObjectException)
55
+ end
56
+ end
57
+
58
+ describe "#id" do
59
+ it "returns the id attribute" do
60
+ browser.span(:index, 0).id.should == "lead"
61
+ end
62
+
63
+ it "returns an empty string if the element exists and the attribute doesn't" do
64
+ browser.span(:index, 2).id.should == ''
65
+ end
66
+
67
+ it "raises UnknownObjectException if the span doesn't exist" do
68
+ lambda { browser.span(:id, "no_such_id").id }.should raise_error(UnknownObjectException)
69
+ lambda { browser.span(:index, 1337).id }.should raise_error(UnknownObjectException)
70
+ end
71
+ end
72
+
73
+ describe "#title" do
74
+ it "returns the title attribute" do
75
+ browser.span(:index, 0).title.should == 'Lorem ipsum'
76
+ end
77
+
78
+ it "returns an empty string if the element exists and the attribute doesn't" do
79
+ browser.span(:index, 2).title.should == ''
80
+ end
81
+
82
+ it "raises UnknownObjectException if the span doesn't exist" do
83
+ lambda { browser.span(:id, 'no_such_id').title }.should raise_error( UnknownObjectException)
84
+ lambda { browser.span(:xpath, "//span[@id='no_such_id']").title }.should raise_error( UnknownObjectException)
85
+ end
86
+ end
87
+
88
+ describe "#text" do
89
+ it "returns the text of the span" do
90
+ browser.span(:index, 1).text.should == '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.'
91
+ end
92
+
93
+ it "returns an empty string if the element doesn't contain any text" do
94
+ browser.span(:index, 4).text.should == ''
95
+ end
96
+
97
+ it "raises UnknownObjectException if the span doesn't exist" do
98
+ lambda { browser.span(:id, 'no_such_id').text }.should raise_error( UnknownObjectException)
99
+ lambda { browser.span(:xpath , "//span[@id='no_such_id']").text }.should raise_error( UnknownObjectException)
100
+ end
101
+ end
102
+
103
+ describe "#value" do
104
+ it "returns the value attribute" do
105
+ browser.span(:index, 1).value.should == "invalid_attribute"
106
+ end
107
+
108
+ it "returns an empty string if the element exists and the attribute doesn't" do
109
+ browser.span(:index, 2).value.should == ''
110
+ end
111
+
112
+ it "raises UnknownObjectException if the span doesn't exist" do
113
+ lambda { browser.span(:id , "no_such_id").value }.should raise_error(UnknownObjectException)
114
+ lambda { browser.span(:index , 1337).value }.should raise_error(UnknownObjectException)
115
+ end
116
+ end
117
+
118
+ describe "#respond_to?" do
119
+ it "returns true for all attribute methods" do
120
+ browser.span(:index, 0).should respond_to(:class_name)
121
+ browser.span(:index, 0).should respond_to(:id)
122
+ browser.span(:index, 0).should respond_to(:title)
123
+ browser.span(:index, 0).should respond_to(:text)
124
+ browser.span(:index, 0).should respond_to(:value)
125
+ end
126
+ end
127
+
128
+ # Other
129
+ describe "#click" do
130
+ it "fires events" do
131
+ browser.span(:class, 'footer').text.should_not include('Javascript')
132
+ browser.span(:class, 'footer').click
133
+ browser.span(:class, 'footer').text.should include('Javascript')
134
+ end
135
+
136
+ it "raises UnknownObjectException if the span doesn't exist" do
137
+ lambda { browser.span(:id, "no_such_id").click }.should raise_error(UnknownObjectException)
138
+ lambda { browser.span(:title, "no_such_title").click }.should raise_error(UnknownObjectException)
139
+ end
140
+ end
141
+
142
+ end
@@ -0,0 +1,31 @@
1
+ # encoding: utf-8
2
+ require File.dirname(__FILE__) + '/spec_helper'
3
+
4
+ describe "Spans" do
5
+
6
+ before :each do
7
+ browser.goto(WatirSpec.files + "/non_control_elements.html")
8
+ end
9
+
10
+ describe "#length" do
11
+ it "returns the number of spans" do
12
+ browser.spans.length.should == 6
13
+ end
14
+ end
15
+
16
+ describe "#[]" do
17
+ it "returns the p at the given index" do
18
+ browser.spans[0].id.should == "lead"
19
+ end
20
+ end
21
+
22
+ describe "#each" do
23
+ it "iterates through spans correctly" do
24
+ browser.spans.each_with_index do |s, index|
25
+ s.id.should == browser.span(:index, index).id
26
+ s.value.should == browser.span(:index, index).value
27
+ end
28
+ end
29
+ end
30
+
31
+ end
@@ -0,0 +1,17 @@
1
+ # encoding: utf-8
2
+ begin
3
+ require "rubygems"
4
+ rescue LoadError
5
+ end
6
+
7
+ require "sinatra/base"
8
+ require "#{File.dirname(__FILE__)}/lib/watirspec"
9
+ require "#{File.dirname(__FILE__)}/lib/server"
10
+ require "#{File.dirname(__FILE__)}/lib/spec_helper"
11
+ require "#{File.dirname(__FILE__)}/lib/guards"
12
+
13
+ if __FILE__ == $0
14
+ WatirSpec::Server.run!
15
+ else
16
+ WatirSpec::SpecHelper.execute
17
+ end
@@ -0,0 +1,89 @@
1
+ # encoding: utf-8
2
+ require File.dirname(__FILE__) + '/spec_helper'
3
+
4
+ describe "Strong" do
5
+
6
+ before :each do
7
+ browser.goto(WatirSpec.files + "/non_control_elements.html")
8
+ end
9
+
10
+ # Exists method
11
+ describe "#exist?" do
12
+ it "returns true if the element exists" do
13
+ browser.strong(:id, "descartes").should exist
14
+ browser.strong(:id, /descartes/).should exist
15
+ browser.strong(:text, "Dubito, ergo cogito, ergo sum.").should exist
16
+ browser.strong(:text, /Dubito, ergo cogito, ergo sum/).should exist
17
+ browser.strong(:class, "descartes").should exist
18
+ browser.strong(:class, /descartes/).should exist
19
+ browser.strong(:index, 0).should exist
20
+ browser.strong(:xpath, "//strong[@id='descartes']").should exist
21
+ end
22
+
23
+ it "returns false if the element doesn't exist" do
24
+ browser.strong(:id, "no_such_id").should_not exist
25
+ browser.strong(:id, /no_such_id/).should_not exist
26
+ browser.strong(:text, "no_such_text").should_not exist
27
+ browser.strong(:text, /no_such_text/).should_not exist
28
+ browser.strong(:class, "no_such_class").should_not exist
29
+ browser.strong(:class, /no_such_class/).should_not exist
30
+ browser.strong(:index, 1337).should_not exist
31
+ browser.strong(:xpath, "//strong[@id='no_such_id']").should_not exist
32
+ end
33
+
34
+ it "raises TypeError when 'what' argument is invalid" do
35
+ lambda { browser.strong(:id, 3.14).exists? }.should raise_error(TypeError)
36
+ end
37
+
38
+ it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
39
+ lambda { browser.strong(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
40
+ end
41
+ end
42
+
43
+ # Attribute methods
44
+ describe "#class_name" do
45
+ it "returns the class attribute" do
46
+ browser.strong(:index, 0).class_name.should == 'descartes'
47
+ end
48
+
49
+ it "returns an empty string if the element exists and the attribute doesn't" do
50
+ browser.strong(:index, 1).class_name.should == ''
51
+ end
52
+
53
+ it "raises UnknownObjectException if the element doesn't exist" do
54
+ lambda { browser.strong(:id, 'no_such_id').class_name }.should raise_error(UnknownObjectException)
55
+ end
56
+ end
57
+
58
+ describe "#id" do
59
+ it "returns the id attribute" do
60
+ browser.strong(:index, 0).id.should == "descartes"
61
+ end
62
+
63
+ it "raises UnknownObjectException if the element doesn't exist" do
64
+ lambda { browser.strong(:id, "no_such_id").id }.should raise_error(UnknownObjectException)
65
+ lambda { browser.strong(:index, 1337).id }.should raise_error(UnknownObjectException)
66
+ end
67
+ end
68
+
69
+ describe "#text" do
70
+ it "returns the text of the element" do
71
+ browser.strong(:index, 0).text.should == "Dubito, ergo cogito, ergo sum."
72
+ end
73
+
74
+ it "raises UnknownObjectException if the element doesn't exist" do
75
+ lambda { browser.strong(:id, 'no_such_id').text }.should raise_error( UnknownObjectException)
76
+ lambda { browser.strong(:xpath , "//strong[@id='no_such_id']").text }.should raise_error( UnknownObjectException)
77
+ end
78
+ end
79
+
80
+ describe "#respond_to?" do
81
+ it "returns true for all attribute methods" do
82
+ browser.strong(:index, 0).should respond_to(:class_name)
83
+ browser.strong(:index, 0).should respond_to(:id)
84
+ browser.strong(:index, 0).should respond_to(:text)
85
+ end
86
+ end
87
+
88
+ # Other
89
+ end
@@ -0,0 +1,32 @@
1
+ # encoding: utf-8
2
+ require File.dirname(__FILE__) + '/spec_helper'
3
+
4
+ describe "Strongs" do
5
+
6
+ before :each do
7
+ browser.goto(WatirSpec.files + "/non_control_elements.html")
8
+ end
9
+
10
+ describe "#length" do
11
+ it "returns the number of divs" do
12
+ browser.strongs.length.should == 2
13
+ end
14
+ end
15
+
16
+ describe "#[]" do
17
+ it "returns the div at the given index" do
18
+ browser.strongs[0].id.should == "descartes"
19
+ end
20
+ end
21
+
22
+ describe "#each" do
23
+ it "iterates through divs correctly" do
24
+ browser.strongs.each_with_index do |s, index|
25
+ strong = browser.strong(:index, index)
26
+ s.id.should == strong.id
27
+ s.class_name.should == strong.class_name
28
+ end
29
+ end
30
+ end
31
+
32
+ end
@@ -0,0 +1,45 @@
1
+ # encoding: utf-8
2
+ require File.dirname(__FILE__) + '/spec_helper'
3
+
4
+ describe "TableBodies" do
5
+
6
+ before :each do
7
+ browser.goto(WatirSpec.files + "/tables.html")
8
+ end
9
+
10
+ describe "#length" do
11
+ it "returns the correct number of table bodies (page context)" do
12
+ browser.tbodys.length.should == 5
13
+ end
14
+
15
+ it "returns the correct number of table bodies (table context)" do
16
+ browser.table(:index, 0).tbodys.length.should == 2
17
+ end
18
+ end
19
+
20
+ describe "#[]" do
21
+ it "returns the row at the given index (page context)" do
22
+ browser.tbodys[0].id.should == "first"
23
+ end
24
+
25
+ it "returns the row at the given index (table context)" do
26
+ browser.table(:index, 0).tbodys[0].id.should == "first"
27
+ end
28
+ end
29
+
30
+ describe "#each" do
31
+ it "iterates through table bodies correctly (table context)" do
32
+ browser.tbodys.each_with_index do |body, index|
33
+ body.id.should == browser.tbody(:index, index).id
34
+ end
35
+ end
36
+
37
+ it "iterates through table bodies correctly (table context)" do
38
+ table = browser.table(:index, 0)
39
+ table.tbodys.each_with_index do |body, index|
40
+ body.id.should == table.tbody(:index, index).id
41
+ end
42
+ end
43
+ end
44
+
45
+ end
@@ -0,0 +1,98 @@
1
+ # encoding: utf-8
2
+ require File.dirname(__FILE__) + '/spec_helper'
3
+
4
+ describe "TableBody" do
5
+
6
+ before :each do
7
+ browser.goto(WatirSpec.files + "/tables.html")
8
+ end
9
+
10
+ describe "#exists?" do
11
+ bug "WTR-357", :watir do
12
+ it "returns true if the table body exists (page context)" do
13
+ browser.tbody(:id, 'first').should exist
14
+ browser.tbody(:id, /first/).should exist
15
+ browser.tbody(:index, 0).should exist
16
+ browser.tbody(:xpath, "//tbody[@id='first']").should exist
17
+ end
18
+ end
19
+
20
+ it "returns true if the table body exists (table context)" do
21
+ browser.table(:index, 0).tbody(:id, 'first').should exist
22
+ browser.table(:index, 0).tbody(:id, /first/).should exist
23
+ browser.table(:index, 0).tbody(:index, 1).should exist
24
+ browser.table(:index, 0).tbody(:xpath, "//tbody[@id='first']").should exist
25
+ end
26
+
27
+ bug "WTR-357", :watir do
28
+ it "returns false if the table body doesn't exist (page context)" do
29
+ browser.tbody(:id, 'no_such_id').should_not exist
30
+ browser.tbody(:id, /no_such_id/).should_not exist
31
+ browser.tbody(:index, 1337).should_not exist
32
+ browser.tbody(:xpath, "//tbody[@id='no_such_id']").should_not exist
33
+ end
34
+ end
35
+
36
+ it "returns false if the table body doesn't exist (table context)" do
37
+ browser.table(:index, 0).tbody(:id, 'no_such_id').should_not exist
38
+ browser.table(:index, 0).tbody(:id, /no_such_id/).should_not exist
39
+ browser.table(:index, 0).tbody(:index, 1337).should_not exist
40
+ browser.table(:index, 0).tbody(:xpath, "//tbody[@id='no_such_id']").should_not exist
41
+ end
42
+
43
+ it "raises TypeError when 'what' argument is invalid" do
44
+ bug "WTR-357", :watir do
45
+ lambda { browser.tbody(:id, 3.14).exists? }.should raise_error(TypeError)
46
+ end
47
+ lambda { browser.table(:index, 0).tbody(:id, 3.14).exists? }.should raise_error(TypeError)
48
+ end
49
+
50
+ it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
51
+ bug "WTR-357", :watir do
52
+ lambda { browser.tbody(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
53
+ end
54
+ lambda { browser.table(:index, 0).tbody(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
55
+ end
56
+ end
57
+
58
+ describe "#length" do
59
+ bug "WTR-357", :watir do
60
+ it "returns the correct number of table bodies (page context)" do
61
+ browser.tbody(:id, 'first').length.should == 3
62
+ end
63
+ end
64
+
65
+ it "returns the correct number of table bodies (table context)" do
66
+ browser.table(:index, 0).tbody(:id, 'first').length.should == 3
67
+ end
68
+ end
69
+
70
+ describe "#[]" do
71
+ bug "WTR-357", :watir do
72
+ it "returns the row at the given index (page context)" do
73
+ browser.tbody(:id, 'first')[0].text.should == 'March 2008'
74
+ browser.tbody(:id, 'first')[1][0].text.should == 'Gregory House'
75
+ browser.tbody(:id, 'first')[2][0].text.should == 'Hugh Laurie'
76
+ end
77
+ end
78
+
79
+ it "returns the row at the given index (table context)" do
80
+ browser.table(:index, 0).tbody(:id, 'first')[0].text.should == 'March 2008'
81
+ browser.table(:index, 0).tbody(:id, 'first')[1][0].text.should == 'Gregory House'
82
+ browser.table(:index, 0).tbody(:id, 'first')[2][0].text.should == 'Hugh Laurie'
83
+ end
84
+ end
85
+
86
+ describe "#each" do
87
+ it "iterates through rows correctly" do
88
+ body = browser.table(:index, 0).tbody(:id, 'first')
89
+ expected_texts = ["march", "gregory", "hugh"]
90
+
91
+ body.each_with_index do |row, idx|
92
+ row.id.should == expected_texts[idx]
93
+ end
94
+
95
+ end
96
+ end
97
+
98
+ end