watir-webdriver 0.0.1.dev

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.
Files changed (125) hide show
  1. data/.document +5 -0
  2. data/.gitignore +5 -0
  3. data/.gitmodules +3 -0
  4. data/LICENSE +20 -0
  5. data/README.rdoc +32 -0
  6. data/Rakefile +107 -0
  7. data/TODO +15 -0
  8. data/VERSION +1 -0
  9. data/lib/watir-webdriver.rb +74 -0
  10. data/lib/watir-webdriver/base_element.rb +347 -0
  11. data/lib/watir-webdriver/browser.rb +130 -0
  12. data/lib/watir-webdriver/browserbot.js +34 -0
  13. data/lib/watir-webdriver/collections/buttons_collection.rb +13 -0
  14. data/lib/watir-webdriver/collections/element_collection.rb +45 -0
  15. data/lib/watir-webdriver/collections/table_rows_collection.rb +14 -0
  16. data/lib/watir-webdriver/collections/text_fields_collection.rb +13 -0
  17. data/lib/watir-webdriver/container.rb +24 -0
  18. data/lib/watir-webdriver/core_ext/string.rb +22 -0
  19. data/lib/watir-webdriver/elements/button.rb +27 -0
  20. data/lib/watir-webdriver/elements/checkbox.rb +23 -0
  21. data/lib/watir-webdriver/elements/file_field.rb +20 -0
  22. data/lib/watir-webdriver/elements/form.rb +11 -0
  23. data/lib/watir-webdriver/elements/generated.rb +941 -0
  24. data/lib/watir-webdriver/elements/headings.rb +48 -0
  25. data/lib/watir-webdriver/elements/hidden.rb +18 -0
  26. data/lib/watir-webdriver/elements/image.rb +33 -0
  27. data/lib/watir-webdriver/elements/input.rb +39 -0
  28. data/lib/watir-webdriver/elements/link.rb +13 -0
  29. data/lib/watir-webdriver/elements/option.rb +36 -0
  30. data/lib/watir-webdriver/elements/radio.rb +23 -0
  31. data/lib/watir-webdriver/elements/select_list.rb +73 -0
  32. data/lib/watir-webdriver/elements/shared_radio_checkbox.rb +13 -0
  33. data/lib/watir-webdriver/elements/table.rb +18 -0
  34. data/lib/watir-webdriver/elements/table_row.rb +17 -0
  35. data/lib/watir-webdriver/elements/text_field.rb +60 -0
  36. data/lib/watir-webdriver/exception.rb +20 -0
  37. data/lib/watir-webdriver/locators/button_locator.rb +57 -0
  38. data/lib/watir-webdriver/locators/element_locator.rb +269 -0
  39. data/lib/watir-webdriver/locators/table_row_locator.rb +25 -0
  40. data/lib/watir-webdriver/locators/text_field_locator.rb +61 -0
  41. data/lib/watir-webdriver/xpath_support.rb +23 -0
  42. data/spec/element_locator_spec.rb +11 -0
  43. data/spec/spec_helper.rb +16 -0
  44. data/spec/watirspec/area_spec.rb +78 -0
  45. data/spec/watirspec/areas_spec.rb +31 -0
  46. data/spec/watirspec/browser_spec.rb +262 -0
  47. data/spec/watirspec/button_spec.rb +242 -0
  48. data/spec/watirspec/buttons_spec.rb +48 -0
  49. data/spec/watirspec/checkbox_spec.rb +272 -0
  50. data/spec/watirspec/checkboxes_spec.rb +32 -0
  51. data/spec/watirspec/dd_spec.rb +136 -0
  52. data/spec/watirspec/dds_spec.rb +31 -0
  53. data/spec/watirspec/div_spec.rb +222 -0
  54. data/spec/watirspec/divs_spec.rb +31 -0
  55. data/spec/watirspec/dl_spec.rb +136 -0
  56. data/spec/watirspec/dls_spec.rb +32 -0
  57. data/spec/watirspec/dt_spec.rb +136 -0
  58. data/spec/watirspec/dts_spec.rb +31 -0
  59. data/spec/watirspec/element_spec.rb +87 -0
  60. data/spec/watirspec/em_spec.rb +110 -0
  61. data/spec/watirspec/ems_spec.rb +32 -0
  62. data/spec/watirspec/filefield_spec.rb +119 -0
  63. data/spec/watirspec/filefields_spec.rb +32 -0
  64. data/spec/watirspec/form_spec.rb +63 -0
  65. data/spec/watirspec/forms_spec.rb +33 -0
  66. data/spec/watirspec/frame_spec.rb +140 -0
  67. data/spec/watirspec/frames_spec.rb +62 -0
  68. data/spec/watirspec/hidden_spec.rb +102 -0
  69. data/spec/watirspec/hiddens_spec.rb +32 -0
  70. data/spec/watirspec/hn_spec.rb +93 -0
  71. data/spec/watirspec/hns_spec.rb +38 -0
  72. data/spec/watirspec/image_spec.rb +207 -0
  73. data/spec/watirspec/images_spec.rb +31 -0
  74. data/spec/watirspec/label_spec.rb +75 -0
  75. data/spec/watirspec/labels_spec.rb +31 -0
  76. data/spec/watirspec/li_spec.rb +127 -0
  77. data/spec/watirspec/lib/guards.rb +59 -0
  78. data/spec/watirspec/lib/server.rb +127 -0
  79. data/spec/watirspec/lib/spec_helper.rb +79 -0
  80. data/spec/watirspec/lib/watirspec.rb +72 -0
  81. data/spec/watirspec/link_spec.rb +165 -0
  82. data/spec/watirspec/links_spec.rb +35 -0
  83. data/spec/watirspec/lis_spec.rb +31 -0
  84. data/spec/watirspec/map_spec.rb +92 -0
  85. data/spec/watirspec/maps_spec.rb +32 -0
  86. data/spec/watirspec/meta_spec.rb +22 -0
  87. data/spec/watirspec/metas_spec.rb +30 -0
  88. data/spec/watirspec/ol_spec.rb +78 -0
  89. data/spec/watirspec/ols_spec.rb +31 -0
  90. data/spec/watirspec/option_spec.rb +173 -0
  91. data/spec/watirspec/p_spec.rb +143 -0
  92. data/spec/watirspec/pre_spec.rb +125 -0
  93. data/spec/watirspec/pres_spec.rb +31 -0
  94. data/spec/watirspec/ps_spec.rb +31 -0
  95. data/spec/watirspec/radio_spec.rb +278 -0
  96. data/spec/watirspec/radios_spec.rb +32 -0
  97. data/spec/watirspec/select_list_spec.rb +318 -0
  98. data/spec/watirspec/select_lists_spec.rb +35 -0
  99. data/spec/watirspec/span_spec.rb +157 -0
  100. data/spec/watirspec/spans_spec.rb +57 -0
  101. data/spec/watirspec/spec_helper.rb +17 -0
  102. data/spec/watirspec/strong_spec.rb +89 -0
  103. data/spec/watirspec/strongs_spec.rb +32 -0
  104. data/spec/watirspec/table_bodies_spec.rb +45 -0
  105. data/spec/watirspec/table_body_spec.rb +98 -0
  106. data/spec/watirspec/table_cell_spec.rb +68 -0
  107. data/spec/watirspec/table_cells_spec.rb +47 -0
  108. data/spec/watirspec/table_footer_spec.rb +85 -0
  109. data/spec/watirspec/table_footers_spec.rb +47 -0
  110. data/spec/watirspec/table_header_spec.rb +85 -0
  111. data/spec/watirspec/table_headers_spec.rb +45 -0
  112. data/spec/watirspec/table_row_spec.rb +87 -0
  113. data/spec/watirspec/table_rows_spec.rb +50 -0
  114. data/spec/watirspec/table_spec.rb +166 -0
  115. data/spec/watirspec/tables_spec.rb +33 -0
  116. data/spec/watirspec/text_field_spec.rb +276 -0
  117. data/spec/watirspec/text_fields_spec.rb +35 -0
  118. data/spec/watirspec/ul_spec.rb +76 -0
  119. data/spec/watirspec/uls_spec.rb +33 -0
  120. data/spec/xpath_builder_spec.rb +49 -0
  121. data/support/html5/html5.idl +815 -0
  122. data/support/html5/html5_extras.idl +147 -0
  123. data/support/html5/idl_extractor.rb +73 -0
  124. data/support/html5/watir_visitor.rb +169 -0
  125. metadata +220 -0
@@ -0,0 +1,93 @@
1
+ # encoding: utf-8
2
+ require File.dirname(__FILE__) + '/spec_helper'
3
+
4
+ describe "H1", "H2", "H3", "H4", "H5", "H6" 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.h1(:id, "header1").should exist
14
+ browser.h2(:id, /header2/).should exist
15
+ browser.h3(:text, "Header 3").should exist
16
+ browser.h4(:text, /Header 4/).should exist
17
+ browser.h5(:index, 0).should exist
18
+ browser.h6(:index, 0).should exist
19
+ browser.h1(:xpath, "//h1[@id='first_header']").should exist
20
+ end
21
+
22
+ it "returns true if the element exists" do
23
+ browser.h1(:id, "no_such_id").should_not exist
24
+ browser.h1(:id, /no_such_id/).should_not exist
25
+ browser.h1(:text, "no_such_text").should_not exist
26
+ browser.h1(:text, /no_such_text 1/).should_not exist
27
+ browser.h1(:index, 1337).should_not exist
28
+ browser.h1(:xpath, "//p[@id='no_such_id']").should_not exist
29
+ end
30
+
31
+ it "raises TypeError when 'what' argument is invalid" do
32
+ lambda { browser.h1(:id, 3.14).exists? }.should raise_error(TypeError)
33
+ end
34
+
35
+ it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
36
+ lambda { browser.h1(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
37
+ end
38
+ end
39
+
40
+ # Attribute methods
41
+ describe "#class_name" do
42
+ it "returns the class attribute" do
43
+ browser.h1(:index, 0).class_name.should == 'primary'
44
+ end
45
+
46
+ it "returns an empty string if the element exists and the attribute doesn't" do
47
+ browser.h2(:index, 0).class_name.should == ''
48
+ end
49
+
50
+ it "raises UnknownObjectException if the p doesn't exist" do
51
+ lambda { browser.h2(:id, 'no_such_id').class_name }.should raise_error(UnknownObjectException)
52
+ end
53
+ end
54
+
55
+ describe "#id" do
56
+ it "returns the id attribute" do
57
+ browser.h1(:index, 0).id.should == "first_header"
58
+ end
59
+
60
+ it "returns an empty string if the element exists and the attribute doesn't" do
61
+ browser.h3(:index, 0).id.should == ''
62
+ end
63
+
64
+ it "raises UnknownObjectException if the p doesn't exist" do
65
+ lambda { browser.h1(:id, "no_such_id").id }.should raise_error(UnknownObjectException)
66
+ lambda { browser.h1(:index, 1337).id }.should raise_error(UnknownObjectException)
67
+ end
68
+ end
69
+
70
+ describe "#text" do
71
+ it "returns the text of the element" do
72
+ browser.h1(:index, 0).text.should == 'Header 1'
73
+ end
74
+
75
+ it "returns an empty string if the element doesn't contain any text" do
76
+ browser.h6(:id, "empty_header").text.should == ''
77
+ end
78
+
79
+ it "raises UnknownObjectException if the p doesn't exist" do
80
+ lambda { browser.h1(:id, 'no_such_id').text }.should raise_error(UnknownObjectException)
81
+ lambda { browser.h1(:xpath , "//h1[@id='no_such_id']").text }.should raise_error(UnknownObjectException)
82
+ end
83
+ end
84
+
85
+ describe "#respond_to?" do
86
+ it "returns true for all attribute methods" do
87
+ browser.h1(:index, 0).should respond_to(:class_name)
88
+ browser.h1(:index, 0).should respond_to(:id)
89
+ browser.h1(:index, 0).should respond_to(:text)
90
+ end
91
+ end
92
+
93
+ end
@@ -0,0 +1,38 @@
1
+ # encoding: utf-8
2
+ require File.dirname(__FILE__) + '/spec_helper'
3
+
4
+ bug "WTR-345", :watir do
5
+
6
+ describe "H1s", "H2s", "H3s", "H4s", "H5s", "H6s" do
7
+ before :each do
8
+ browser.goto(WatirSpec.files + "/non_control_elements.html")
9
+ end
10
+
11
+ describe "#length" do
12
+ it "returns the number of h1s" do
13
+ browser.h2s.length.should == 9
14
+ end
15
+ end
16
+
17
+ describe "#[]" do
18
+ it "returns the h1 at the given index" do
19
+ browser.h1s[0].id.should == "first_header"
20
+ end
21
+ end
22
+
23
+ describe "#each" do
24
+ it "iterates through header collections correctly" do
25
+ lengths = (1..6).collect do |i|
26
+ collection = browser.send(:"h#{i}s")
27
+ collection.each_with_index do |h, index|
28
+ h.id.should == browser.send(:"h#{i}", :index, index).id
29
+ h.value.should == browser.send(:"h#{i}", :index, index).value
30
+ end
31
+ collection.length
32
+ end
33
+ lengths.should == [2, 9, 2, 1, 1, 2]
34
+ end
35
+ end
36
+ end
37
+
38
+ end
@@ -0,0 +1,207 @@
1
+ # encoding: utf-8
2
+ require File.dirname(__FILE__) + '/spec_helper'
3
+
4
+ describe "Image" do
5
+
6
+ before :each do
7
+ browser.goto(WatirSpec.files + "/images.html")
8
+ end
9
+
10
+ # Exists method
11
+ describe "#exists?" do
12
+ it "returns true when the image exists" do
13
+ browser.image(:id, 'square').should exist
14
+ browser.image(:id, /square/).should exist
15
+
16
+ bug "WTR-347", :watir do
17
+ browser.image(:src, 'images/circle.jpg').should exist
18
+ end
19
+
20
+ browser.image(:src, /circle/).should exist
21
+ browser.image(:alt, 'circle').should exist
22
+ browser.image(:alt, /cir/).should exist
23
+ browser.image(:title, 'Circle').should exist
24
+ end
25
+
26
+ it "returns false when the image doesn't exist" do
27
+ browser.image(:id, 'no_such_id').should_not exist
28
+ browser.image(:id, /no_such_id/).should_not exist
29
+ browser.image(:src, 'no_such_src').should_not exist
30
+ browser.image(:src, /no_such_src/).should_not exist
31
+ browser.image(:alt, 'no_such_alt').should_not exist
32
+ browser.image(:alt, /no_such_alt/).should_not exist
33
+ browser.image(:title, 'no_such_title').should_not exist
34
+ browser.image(:title, /no_such_title/).should_not exist
35
+ end
36
+
37
+ it "raises TypeError when 'what' argument is invalid" do
38
+ lambda { browser.image(:id, 3.14).exists? }.should raise_error(TypeError)
39
+ end
40
+
41
+ it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
42
+ lambda { browser.image(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
43
+ end
44
+ end
45
+
46
+ # Attribute methods
47
+ describe "#alt" do
48
+ it "returns the alt attribute of the image if the image exists" do
49
+ browser.image(:id, 'square').alt.should == "square"
50
+ browser.image(:title, 'Circle').alt.should == 'circle'
51
+ end
52
+
53
+ it "returns an empty string if the image exists and the attribute doesn't" do
54
+ browser.image(:index, 0).alt.should == ""
55
+ end
56
+
57
+ it "raises UnknownObjectException if the image doesn't exist" do
58
+ lambda { browser.image(:index, 1337).alt }.should raise_error(UnknownObjectException)
59
+ end
60
+ end
61
+
62
+ describe "#id" do
63
+ it "returns the id attribute of the image if the image exists" do
64
+ browser.image(:title, 'Square').id.should == 'square'
65
+ end
66
+
67
+ it "returns an empty string if the image exists and the attribute doesn't" do
68
+ browser.image(:index, 0).id.should == ""
69
+ end
70
+
71
+ it "raises UnknownObjectException if the image doesn't exist" do
72
+ lambda { browser.image(:index, 1337).id }.should raise_error(UnknownObjectException)
73
+ end
74
+ end
75
+
76
+ describe "#src" do
77
+ it "returns the src attribute of the image if the image exists" do
78
+ browser.image(:id, 'square').src.should =~ /square\.jpg/i
79
+ end
80
+
81
+ it "returns an empty string if the image exists and the attribute doesn't" do
82
+ browser.image(:index, 0).src.should == ""
83
+ end
84
+
85
+ it "raises UnknownObjectException if the image doesn't exist" do
86
+ lambda { browser.image(:index, 1337).src }.should raise_error(UnknownObjectException)
87
+ end
88
+ end
89
+
90
+ describe "#title" do
91
+ it "returns the title attribute of the image if the image exists" do
92
+ browser.image(:id, 'square').title.should == 'Square'
93
+ end
94
+
95
+ it "returns an empty string if the image exists and the attribute doesn't" do
96
+ browser.image(:index, 0).title.should == ""
97
+ end
98
+
99
+ it "raises UnknownObjectException if the image doesn't exist" do
100
+ lambda { browser.image(:index, 1337).title }.should raise_error(UnknownObjectException)
101
+ end
102
+ end
103
+
104
+ describe "#respond_to?" do
105
+ it "returns true for all attribute methods" do
106
+ browser.image(:index, 0).should respond_to(:class_name)
107
+ browser.image(:index, 0).should respond_to(:id)
108
+ browser.image(:index, 0).should respond_to(:style)
109
+ browser.image(:index, 0).should respond_to(:text)
110
+ browser.image(:index, 0).should respond_to(:value)
111
+ end
112
+ end
113
+
114
+ # Manipulation methods
115
+ describe "#click" do
116
+ it "raises UnknownObjectException when the image doesn't exist" do
117
+ lambda { browser.image(:id, 'missing_attribute').click }.should raise_error(UnknownObjectException)
118
+ lambda { browser.image(:class, 'missing_attribute').click }.should raise_error(UnknownObjectException)
119
+ lambda { browser.image(:src, 'missing_attribute').click }.should raise_error(UnknownObjectException)
120
+ lambda { browser.image(:alt, 'missing_attribute').click }.should raise_error(UnknownObjectException)
121
+ end
122
+ end
123
+
124
+ # File methods
125
+ bug "WTR-347", :watir do
126
+ describe "#file_created_date" do
127
+ it "returns the date the image was created as reported by the file system" do
128
+ browser.goto(WatirSpec.host + "/images.html")
129
+ image = browser.image(:index, 1)
130
+ path = "#{File.dirname(__FILE__)}/html/#{image.src}"
131
+ image.file_created_date.to_i.should == File.mtime(path).to_i
132
+ end
133
+ end
134
+ end
135
+
136
+
137
+ bug "WTR-346", :watir do
138
+ describe "#file_size" do
139
+ it "returns the file size of the image if the image exists" do
140
+ browser.image(:id, 'square').file_size.should == File.size("#{WatirSpec.files}/images/square.jpg".sub("file://", ''))
141
+ end
142
+ end
143
+
144
+ it "raises UnknownObjectException if the image doesn't exist" do
145
+ lambda { browser.image(:index, 1337).file_size }.should raise_error(UnknownObjectException)
146
+ end
147
+ end
148
+
149
+ describe "#height" do
150
+ not_compliant_on :watir do
151
+ it "returns the height of the image if the image exists" do
152
+ browser.image(:id, 'square').height.should == 88
153
+ end
154
+ end
155
+
156
+ it "raises UnknownObjectException if the image doesn't exist" do
157
+ lambda { browser.image(:index, 1337).height }.should raise_error(UnknownObjectException)
158
+ end
159
+ end
160
+
161
+ describe "#width" do
162
+ not_compliant_on :watir do
163
+ it "returns the width of the image if the image exists" do
164
+ browser.image(:id, 'square').width.should == 88
165
+ end
166
+ end
167
+
168
+ it "raises UnknownObjectException if the image doesn't exist" do
169
+ lambda { browser.image(:index, 1337).width }.should raise_error(UnknownObjectException)
170
+ end
171
+ end
172
+
173
+ # Other
174
+ describe "#loaded?" do
175
+ it "returns true if the image has been loaded" do
176
+ browser.image(:title, 'Circle').should be_loaded
177
+ browser.image(:alt, 'circle').should be_loaded
178
+ browser.image(:alt, /circle/).should be_loaded
179
+ end
180
+
181
+ it "returns false if the image has not been loaded" do
182
+ browser.image(:id, 'no_such_file').should_not be_loaded
183
+ end
184
+
185
+ it "raises UnknownObjectException if the image doesn't exist" do
186
+ lambda { browser.image(:id, 'no_such_image').loaded? }.should raise_error(UnknownObjectException)
187
+ lambda { browser.image(:src, 'no_such_image').loaded? }.should raise_error(UnknownObjectException)
188
+ lambda { browser.image(:alt, 'no_such_image').loaded? }.should raise_error(UnknownObjectException)
189
+ lambda { browser.image(:index, 1337).loaded? }.should raise_error(UnknownObjectException)
190
+ end
191
+ end
192
+
193
+ describe "#save" do
194
+ bug "WTR-336", :watir do
195
+ it "saves the image to a file" do
196
+ file = "#{File.expand_path Dir.pwd}/sample.img.dat"
197
+ begin
198
+ browser.image(:index, 1).save(file)
199
+ File.exist?(file).should be_true
200
+ ensure
201
+ File.delete(file) if File.exist?(file)
202
+ end
203
+ end
204
+ end
205
+ end
206
+
207
+ end
@@ -0,0 +1,31 @@
1
+ # encoding: utf-8
2
+ require File.dirname(__FILE__) + '/spec_helper'
3
+
4
+ describe "Images" do
5
+
6
+ before :each do
7
+ browser.goto(WatirSpec.files + "/images.html")
8
+ end
9
+
10
+ describe "#length" do
11
+ it "returns the number of images" do
12
+ browser.images.length.should == 9
13
+ end
14
+ end
15
+
16
+ describe "#[]" do
17
+ it "returns the image at the given index" do
18
+ browser.images[5].id.should == "square"
19
+ end
20
+ end
21
+
22
+ describe "#each" do
23
+ it "iterates through images correctly" do
24
+ browser.images.each_with_index do |c, index|
25
+ c.id.should == browser.image(:index, index).id
26
+ c.value.should == browser.image(:index, index).value
27
+ end
28
+ end
29
+ end
30
+
31
+ end
@@ -0,0 +1,75 @@
1
+ # encoding: utf-8
2
+ require File.dirname(__FILE__) + '/spec_helper'
3
+
4
+ describe "Label" do
5
+
6
+ before :each do
7
+ browser.goto(WatirSpec.files + "/forms_with_input_elements.html")
8
+ end
9
+
10
+ # Exists method
11
+ describe "#exists?" do
12
+ it "returns true if the element exists" do
13
+ browser.label(:id, 'first_label').should exist
14
+ browser.label(:id, /first_label/).should exist
15
+ browser.label(:text, 'First name').should exist
16
+ browser.label(:text, /First name/).should exist
17
+ browser.label(:index, 0).should exist
18
+ browser.label(:xpath, "//label[@id='first_label']").should exist
19
+ end
20
+
21
+ it "returns false if the element does not exist" do
22
+ browser.label(:id, 'no_such_id').should_not exist
23
+ browser.label(:id, /no_such_id/).should_not exist
24
+ browser.label(:text, 'no_such_text').should_not exist
25
+ browser.label(:text, /no_such_text/).should_not exist
26
+ browser.label(:index, 1337).should_not exist
27
+ browser.label(:xpath, "//input[@id='no_such_id']").should_not exist
28
+ end
29
+
30
+ it "raises TypeError when 'what' argument is invalid" do
31
+ lambda { browser.label(:id, 3.14).exists? }.should raise_error(TypeError)
32
+ end
33
+
34
+ it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
35
+ lambda { browser.label(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
36
+ end
37
+ end
38
+
39
+ describe "click" do
40
+ it "fires the onclick event" do
41
+ browser.label(:id, 'first_label').click
42
+ messages.first.should == 'label'
43
+ end
44
+ end
45
+
46
+ # Attribute methods
47
+ describe "#id" do
48
+ it "returns the id attribute if the label exists" do
49
+ browser.label(:index, 0).id.should == "first_label"
50
+ end
51
+
52
+ it "raises UnknownObjectException if the label doesn't exist" do
53
+ lambda { browser.label(:index, 1337).id }.should raise_error(UnknownObjectException)
54
+ end
55
+ end
56
+
57
+ describe "#for" do
58
+ it "returns the 'for' attribute if the label exists" do
59
+ browser.label(:index, 0).for.should == "new_user_first_name"
60
+ end
61
+
62
+ it "raises UnknownObjectException if the label doesn't exist" do
63
+ lambda { browser.label(:index, 1337).for }.should raise_error(UnknownObjectException)
64
+ end
65
+ end
66
+
67
+ describe "#respond_to?" do
68
+ it "returns true for all attribute methods" do
69
+ browser.label(:index, 0).should respond_to(:id)
70
+ browser.label(:index, 0).should respond_to(:for)
71
+ end
72
+ end
73
+
74
+
75
+ end