watir-webdriver 0.0.1.dev6 → 0.0.1.dev7

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 (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,168 @@
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
+ not_compliant_on :webdriver do
26
+ # not a technical issue - just not sure if it's really the behaviour we want
27
+ it "strips spaces from URL attributes when locating elements" do
28
+ browser.link(:url, /strip_space$/).should exist
29
+ end
30
+ end
31
+
32
+ it "returns false if the link doesn't exist" do
33
+ browser.link(:id, 'no_such_id').should_not exist
34
+ browser.link(:id, /no_such_id/).should_not exist
35
+ browser.link(:title, "no_such_title").should_not exist
36
+ browser.link(:title, /no_such_title/).should_not exist
37
+ browser.link(:text, "no_such_text").should_not exist
38
+ browser.link(:text, /no_such_text/i).should_not exist
39
+ browser.link(:url, 'no_such_href').should_not exist
40
+ browser.link(:url, /no_such_href/).should_not exist
41
+ browser.link(:index, 1337).should_not exist
42
+ browser.link(:xpath, "//a[@id='no_such_id']").should_not exist
43
+ end
44
+
45
+ it "raises TypeError when 'what' argument is invalid" do
46
+ lambda { browser.link(:id, 3.14).exists? }.should raise_error(TypeError)
47
+ end
48
+
49
+ it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
50
+ lambda { browser.link(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
51
+ end
52
+ end
53
+
54
+ # Attribute methods
55
+ describe "#class_name" do
56
+ it "returns the type attribute if the link exists" do
57
+ browser.link(:index, 1).class_name.should == "external"
58
+ end
59
+
60
+ it "returns an empty string if the link exists and the attribute doesn't" do
61
+ browser.link(:index, 0).class_name.should == ''
62
+ end
63
+
64
+ it "raises an UnknownObjectException if the link doesn't exist" do
65
+ lambda { browser.link(:index, 1337).class_name }.should raise_error(UnknownObjectException)
66
+ end
67
+ end
68
+
69
+ describe "#href" do
70
+ it "returns the href attribute if the link exists" do
71
+ browser.link(:index, 1).href.should =~ /non_control_elements/
72
+ end
73
+
74
+ it "returns an empty string if the link exists and the attribute doesn't" do
75
+ browser.link(:index, 0).href.should == ""
76
+ end
77
+
78
+ it "raises an UnknownObjectException if the link doesn't exist" do
79
+ lambda { browser.link(:index, 1337).href }.should raise_error(UnknownObjectException)
80
+ end
81
+ end
82
+
83
+ bug "WTR-366", :watir do
84
+ describe "#url" do
85
+ it "returns the href attribute" do
86
+ browser.link(:index, 1).url.should =~ /non_control_elements/
87
+ end
88
+ end
89
+ end
90
+
91
+ describe "#id" do
92
+ it "returns the id attribute if the link exists" do
93
+ browser.link(:index, 1).id.should == "link_2"
94
+ end
95
+
96
+ it "returns an empty string if the link exists and the attribute doesn't" do
97
+ browser.link(:index, 0).id.should == ""
98
+ end
99
+
100
+ it "raises an UnknownObjectException if the link doesn't exist" do
101
+ lambda { browser.link(:index, 1337).id }.should raise_error(UnknownObjectException)
102
+ end
103
+ end
104
+
105
+ describe "#text" do
106
+ it "returns the link text" do
107
+ browser.link(:index, 1).text.should == "Link 2"
108
+ end
109
+
110
+ it "returns an empty string if the link exists and contains no text" do
111
+ browser.link(:index, 0).text.should == ""
112
+ end
113
+
114
+ it "raises an UnknownObjectException if the link doesn't exist" do
115
+ lambda { browser.link(:index, 1337).text }.should raise_error(UnknownObjectException)
116
+ end
117
+ end
118
+
119
+ describe "#title" do
120
+ it "returns the type attribute if the link exists" do
121
+ browser.link(:index, 1).title.should == "link_title_2"
122
+ end
123
+
124
+ it "returns an empty string if the link exists and the attribute doesn't" do
125
+ browser.link(:index, 0).title.should == ""
126
+ end
127
+
128
+ it "raises an UnknownObjectException if the link doesn't exist" do
129
+ lambda { browser.link(:index, 1337).title }.should raise_error(UnknownObjectException)
130
+ end
131
+ end
132
+
133
+ describe "#respond_to?" do
134
+ it "returns true for all attribute methods" do
135
+ browser.link(:index, 0).should respond_to(:class_name)
136
+ browser.link(:index, 0).should respond_to(:href)
137
+ browser.link(:index, 0).should respond_to(:url)
138
+ browser.link(:index, 0).should respond_to(:id)
139
+ browser.link(:index, 0).should respond_to(:style)
140
+ browser.link(:index, 0).should respond_to(:text)
141
+ browser.link(:index, 0).should respond_to(:title)
142
+ end
143
+ end
144
+
145
+ # Manipulation methods
146
+ describe "#click" do
147
+ it "finds an existing link by (:text, String) and click it" do
148
+ browser.link(:text, "Link 3").click
149
+ browser.text.include?("User administration").should be_true
150
+ end
151
+
152
+ it "finds an existing link by (:text, Regexp) and click it" do
153
+ browser.link(:url, /forms_with_input_elements/).click
154
+ browser.text.include?("User administration").should be_true
155
+ end
156
+
157
+ it "finds an existing link by (:index, Integer) and click it" do
158
+ browser.link(:index, 2).click
159
+ browser.text.include?("User administration").should be_true
160
+ end
161
+
162
+ it "raises an UnknownObjectException if the link doesn't exist" do
163
+ lambda { browser.link(:index, 1337).click }.should raise_error(UnknownObjectException)
164
+ end
165
+
166
+ end
167
+
168
+ 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,76 @@
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 map 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
+ 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