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,165 @@
1
+ # encoding: utf-8
2
+ require File.dirname(__FILE__) + '/spec_helper'
3
+
4
+ describe "Link" 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 link exists" do
13
+ browser.link(:id, 'link_2').should exist
14
+ browser.link(:id, /link_2/).should exist
15
+ browser.link(:title, "link_title_2").should exist
16
+ browser.link(:title, /link_title_2/).should exist
17
+ browser.link(:text, "Link 2").should exist
18
+ browser.link(:text, /Link 2/i).should exist
19
+ browser.link(:url, 'non_control_elements.html').should exist
20
+ browser.link(:url, /non_control_elements.html/).should exist
21
+ browser.link(:index, 1).should exist
22
+ browser.link(:xpath, "//a[@id='link_2']").should exist
23
+ end
24
+
25
+ it "strips spaces from URL attributes when locating elements" do
26
+ browser.link(:url, /strip_space$/).should exist
27
+ end
28
+
29
+ it "returns false if the link doesn't exist" do
30
+ browser.link(:id, 'no_such_id').should_not exist
31
+ browser.link(:id, /no_such_id/).should_not exist
32
+ browser.link(:title, "no_such_title").should_not exist
33
+ browser.link(:title, /no_such_title/).should_not exist
34
+ browser.link(:text, "no_such_text").should_not exist
35
+ browser.link(:text, /no_such_text/i).should_not exist
36
+ browser.link(:url, 'no_such_href').should_not exist
37
+ browser.link(:url, /no_such_href/).should_not exist
38
+ browser.link(:index, 1337).should_not exist
39
+ browser.link(:xpath, "//a[@id='no_such_id']").should_not exist
40
+ end
41
+
42
+ it "raises TypeError when 'what' argument is invalid" do
43
+ lambda { browser.link(:id, 3.14).exists? }.should raise_error(TypeError)
44
+ end
45
+
46
+ it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
47
+ lambda { browser.link(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
48
+ end
49
+ end
50
+
51
+ # Attribute methods
52
+ describe "#class_name" do
53
+ it "returns the type attribute if the link exists" do
54
+ browser.link(:index, 1).class_name.should == "external"
55
+ end
56
+
57
+ it "returns an empty string if the link exists and the attribute doesn't" do
58
+ browser.link(:index, 0).class_name.should == ''
59
+ end
60
+
61
+ it "raises an UnknownObjectException if the link doesn't exist" do
62
+ lambda { browser.link(:index, 1337).class_name }.should raise_error(UnknownObjectException)
63
+ end
64
+ end
65
+
66
+ describe "#href" do
67
+ it "returns the href attribute if the link exists" do
68
+ browser.link(:index, 1).href.should =~ /non_control_elements/
69
+ end
70
+
71
+ it "returns an empty string if the link exists and the attribute doesn't" do
72
+ browser.link(:index, 0).href.should == ""
73
+ end
74
+
75
+ it "raises an UnknownObjectException if the link doesn't exist" do
76
+ lambda { browser.link(:index, 1337).href }.should raise_error(UnknownObjectException)
77
+ end
78
+ end
79
+
80
+ bug "WTR-366", :watir do
81
+ describe "#url" do
82
+ it "returns the href attribute" do
83
+ browser.link(:index, 1).url.should =~ /non_control_elements/
84
+ end
85
+ end
86
+ end
87
+
88
+ describe "#id" do
89
+ it "returns the id attribute if the link exists" do
90
+ browser.link(:index, 1).id.should == "link_2"
91
+ end
92
+
93
+ it "returns an empty string if the link exists and the attribute doesn't" do
94
+ browser.link(:index, 0).id.should == ""
95
+ end
96
+
97
+ it "raises an UnknownObjectException if the link doesn't exist" do
98
+ lambda { browser.link(:index, 1337).id }.should raise_error(UnknownObjectException)
99
+ end
100
+ end
101
+
102
+ describe "#text" do
103
+ it "returns the link text" do
104
+ browser.link(:index, 1).text.should == "Link 2"
105
+ end
106
+
107
+ it "returns an empty string if the link exists and contains no text" do
108
+ browser.link(:index, 0).text.should == ""
109
+ end
110
+
111
+ it "raises an UnknownObjectException if the link doesn't exist" do
112
+ lambda { browser.link(:index, 1337).text }.should raise_error(UnknownObjectException)
113
+ end
114
+ end
115
+
116
+ describe "#title" do
117
+ it "returns the type attribute if the link exists" do
118
+ browser.link(:index, 1).title.should == "link_title_2"
119
+ end
120
+
121
+ it "returns an empty string if the link exists and the attribute doesn't" do
122
+ browser.link(:index, 0).title.should == ""
123
+ end
124
+
125
+ it "raises an UnknownObjectException if the link doesn't exist" do
126
+ lambda { browser.link(:index, 1337).title }.should raise_error(UnknownObjectException)
127
+ end
128
+ end
129
+
130
+ describe "#respond_to?" do
131
+ it "returns true for all attribute methods" do
132
+ browser.link(:index, 0).should respond_to(:class_name)
133
+ browser.link(:index, 0).should respond_to(:href)
134
+ browser.link(:index, 0).should respond_to(:url)
135
+ browser.link(:index, 0).should respond_to(:id)
136
+ browser.link(:index, 0).should respond_to(:style)
137
+ browser.link(:index, 0).should respond_to(:text)
138
+ browser.link(:index, 0).should respond_to(:title)
139
+ end
140
+ end
141
+
142
+ # Manipulation methods
143
+ describe "#click" do
144
+ it "finds an existing link by (:text, String) and click it" do
145
+ browser.link(:text, "Link 3").click
146
+ browser.text.include?("User administration").should be_true
147
+ end
148
+
149
+ it "finds an existing link by (:text, Regexp) and click it" do
150
+ browser.link(:url, /forms_with_input_elements/).click
151
+ browser.text.include?("User administration").should be_true
152
+ end
153
+
154
+ it "finds an existing link by (:index, Integer) and click it" do
155
+ browser.link(:index, 2).click
156
+ browser.text.include?("User administration").should be_true
157
+ end
158
+
159
+ it "raises an UnknownObjectException if the link doesn't exist" do
160
+ lambda { browser.link(:index, 1337).click }.should raise_error(UnknownObjectException)
161
+ end
162
+
163
+ end
164
+
165
+ end
@@ -0,0 +1,35 @@
1
+ # encoding: utf-8
2
+ require File.dirname(__FILE__) + '/spec_helper'
3
+
4
+ describe "Links" 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 links" do
12
+ browser.links.length.should == 4
13
+ end
14
+ end
15
+
16
+ describe "#[]" do
17
+ it "returns the link at the given index" do
18
+ browser.links[2].id.should == "link_3"
19
+ end
20
+
21
+ it "returns a Link object also when the index is out of bounds" do
22
+ browser.links[2000].should_not be_nil
23
+ end
24
+ end
25
+
26
+ describe "#each" do
27
+ it "iterates through links correctly" do
28
+ browser.links.each_with_index do |c, index|
29
+ c.id.should == browser.link(:index, index).id
30
+ c.value.should == browser.link(:index, index).value
31
+ end
32
+ end
33
+ end
34
+
35
+ end
@@ -0,0 +1,31 @@
1
+ # encoding: utf-8
2
+ require File.dirname(__FILE__) + '/spec_helper'
3
+
4
+ describe "Lis" 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 lis" do
12
+ browser.lis.length.should == 18
13
+ end
14
+ end
15
+
16
+ describe "#[]" do
17
+ it "returns the li at the given index" do
18
+ browser.lis[4].id.should == "non_link_1"
19
+ end
20
+ end
21
+
22
+ describe "#each" do
23
+ it "iterates through lis correctly" do
24
+ browser.lis.each_with_index do |l, index|
25
+ l.id.should == browser.li(:index, index).id
26
+ l.value.should == browser.li(:index, index).value
27
+ end
28
+ end
29
+ end
30
+
31
+ end
@@ -0,0 +1,92 @@
1
+ # encoding: utf-8
2
+ require File.dirname(__FILE__) + '/spec_helper'
3
+
4
+ describe "Map" do
5
+
6
+ before :each do
7
+ browser.goto(WatirSpec.files + "/images.html")
8
+ end
9
+
10
+ # Exists method
11
+ describe "#exist?" do
12
+ it "returns true if the 'map' exists" do
13
+ browser.map(:id, "triangle_map").should exist
14
+ browser.map(:id, /triangle_map/).should exist
15
+ browser.map(:name, "triangle_map").should exist
16
+ browser.map(:name, /triangle_map/).should exist
17
+ browser.map(:index, 0).should exist
18
+ browser.map(:xpath, "//map[@id='triangle_map']").should exist
19
+ end
20
+
21
+ it "returns false if the 'map' doesn't exist" do
22
+ browser.map(:id, "no_such_id").should_not exist
23
+ browser.map(:id, /no_such_id/).should_not exist
24
+ browser.map(:name, "no_such_id").should_not exist
25
+ browser.map(:name, /no_such_id/).should_not exist
26
+ browser.map(:index, 1337).should_not exist
27
+ browser.map(:xpath, "//map[@id='no_such_id']").should_not exist
28
+ end
29
+
30
+ it "raises TypeError when 'what' argument is invalid" do
31
+ lambda { browser.map(:id, 3.14).exists? }.should raise_error(TypeError)
32
+ end
33
+
34
+ it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
35
+ lambda { browser.map(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
36
+ end
37
+ end
38
+
39
+ # Attribute methods
40
+ describe "#id" do
41
+ it "returns the id attribute" do
42
+ browser.map(:index, 0).id.should == "triangle_map"
43
+ end
44
+
45
+ it "returns an empty string if the element exists and the attribute doesn't" do
46
+ browser.map(:index, 1).id.should == ''
47
+ end
48
+
49
+ it "raises UnknownObjectException if the p doesn't exist" do
50
+ lambda { browser.map(:id, "no_such_id").id }.should raise_error(UnknownObjectException)
51
+ lambda { browser.map(:index, 1337).id }.should raise_error(UnknownObjectException)
52
+ end
53
+ end
54
+
55
+ describe "#name" do
56
+ it "returns the name attribute" do
57
+ browser.map(:index, 0).name.should == "triangle_map"
58
+ end
59
+
60
+ it "returns an empty string if the element exists and the attribute doesn't" do
61
+ browser.map(:index, 1).name.should == ''
62
+ end
63
+
64
+ it "raises UnknownObjectException if the p doesn't exist" do
65
+ lambda { browser.map(:id, "no_such_id").name }.should raise_error(UnknownObjectException)
66
+ lambda { browser.map(:index, 1337).name }.should raise_error(UnknownObjectException)
67
+ end
68
+ end
69
+
70
+ describe "#respond_to?" do
71
+ it "returns true for all attribute methods" do
72
+ browser.map(:index, 0).should respond_to(:id)
73
+ browser.map(:index, 0).should respond_to(:name)
74
+ end
75
+ end
76
+
77
+ # Other
78
+ describe "#to_s" do
79
+ bug "WTR-350", :watir do
80
+ it "returns a human readable representation of the element" do
81
+ browser.map(:index, 0).to_s.should == "tag: map\n" +
82
+ " id: triangle_map\n" +
83
+ " name: triangle_map"
84
+ end
85
+ end
86
+
87
+ it "raises UnknownObjectException if the p doesn't exist" do
88
+ lambda { browser.map(:xpath, "//map[@id='no_such_id']").text }.should raise_error( UnknownObjectException)
89
+ end
90
+ end
91
+
92
+ end
@@ -0,0 +1,32 @@
1
+ # encoding: utf-8
2
+ require File.dirname(__FILE__) + '/spec_helper'
3
+
4
+ describe "Maps" 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 maps" do
12
+ browser.maps.length.should == 2
13
+ end
14
+ end
15
+
16
+ describe "#[]" do
17
+ it "returns the p at the given index" do
18
+ browser.maps[0].id.should == "triangle_map"
19
+ end
20
+ end
21
+
22
+ describe "#each" do
23
+ it "iterates through maps correctly" do
24
+ browser.maps.each_with_index do |m, index|
25
+ m.name.should == browser.map(:index, index).name
26
+ m.id.should == browser.map(:index, index).id
27
+ m.value.should == browser.map(:index, index).value
28
+ end
29
+ end
30
+ end
31
+
32
+ end
@@ -0,0 +1,22 @@
1
+ # encoding: utf-8
2
+ require File.dirname(__FILE__) + '/spec_helper'
3
+
4
+ bug "WTR-334", :watir do
5
+ describe "Meta" do
6
+ before :each do
7
+ browser.goto(WatirSpec.files + "/forms_with_input_elements.html")
8
+ end
9
+
10
+ describe "#exist?" do
11
+ it "returns true if the meta tag exists" do
12
+ browser.meta(:http_equiv, "Content-Type").should exist
13
+ end
14
+ end
15
+
16
+ describe "content" do
17
+ it "returns the content attribute of the tag" do
18
+ browser.meta(:http_equiv, "Content-Type").content.should == "text/html; charset=utf-8"
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,30 @@
1
+ # encoding: utf-8
2
+ require File.dirname(__FILE__) + '/spec_helper'
3
+
4
+ describe "Metas" 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 number of meta elements" do
12
+ browser.metas.length.should == 2
13
+ end
14
+ end
15
+
16
+ describe "#[]" do
17
+ it "returns the meta element at the given index" do
18
+ browser.metas[1].name.should == "description"
19
+ end
20
+ end
21
+
22
+ describe "#each" do
23
+ it "iterates through meta elements correctly" do
24
+ browser.metas.each_with_index do |m, index|
25
+ m.content.should == browser.meta(:index, index).content
26
+ end
27
+ end
28
+ end
29
+
30
+ end
@@ -0,0 +1,78 @@
1
+ # encoding: utf-8
2
+ require File.dirname(__FILE__) + '/spec_helper'
3
+
4
+ bug "WTR-333", :watir do
5
+ describe "Ol" do
6
+
7
+ before :each do
8
+ browser.goto(WatirSpec.files + "/non_control_elements.html")
9
+ end
10
+
11
+ # Exists method
12
+ describe "#exist?" do
13
+ it "returns true if the 'ol' exists" do
14
+ browser.ol(:id, "favorite_compounds").should exist
15
+ browser.ol(:id, /favorite_compounds/).should exist
16
+ browser.ol(:index, 0).should exist
17
+ browser.ol(:xpath, "//ol[@id='favorite_compounds']").should exist
18
+ end
19
+
20
+ it "returns false if the 'ol' doesn't exist" do
21
+ browser.ol(:id, "no_such_id").should_not exist
22
+ browser.ol(:id, /no_such_id/).should_not exist
23
+ browser.ol(:text, "no_such_text").should_not exist
24
+ browser.ol(:text, /no_such_text/).should_not exist
25
+ browser.ol(:class, "no_such_class").should_not exist
26
+ browser.ol(:class, /no_such_class/).should_not exist
27
+ browser.ol(:index, 1337).should_not exist
28
+ browser.ol(:xpath, "//ol[@id='no_such_id']").should_not exist
29
+ end
30
+
31
+ it "raises TypeError when 'what' argument is invalid" do
32
+ lambda { browser.ol(:id, 3.14).exists? }.should raise_error(TypeError)
33
+ end
34
+
35
+ it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
36
+ lambda { browser.ol(: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.ol(:id, 'favorite_compounds').class_name.should == 'chemistry'
44
+ end
45
+
46
+ it "returns an empty string if the element exists and the attribute doesn't" do
47
+ browser.ol(:index, 1).class_name.should == ''
48
+ end
49
+
50
+ it "raises UnknownObjectException if the ol doesn't exist" do
51
+ lambda { browser.ol(: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.ol(:class, 'chemistry').id.should == "favorite_compounds"
58
+ end
59
+
60
+ it "returns an empty string if the element exists and the attribute doesn't" do
61
+ browser.ol(:index, 1).id.should == ''
62
+ end
63
+
64
+ it "raises UnknownObjectException if the ol doesn't exist" do
65
+ lambda { browser.ol(:id, "no_such_id").id }.should raise_error(UnknownObjectException)
66
+ lambda { browser.ol(:index, 1337).id }.should raise_error(UnknownObjectException)
67
+ end
68
+ end
69
+
70
+ describe "#respond_to?" do
71
+ it "returns true for all attribute methods" do
72
+ browser.ol(:index, 0).should respond_to(:class_name)
73
+ browser.ol(:index, 0).should respond_to(:id)
74
+ end
75
+ end
76
+
77
+ end
78
+ end