watir-webdriver 0.0.7 → 0.0.8
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.
- data/Gemfile +2 -0
- data/Gemfile.lock +48 -0
- data/Rakefile +23 -8
- data/VERSION +1 -1
- data/lib/watir-webdriver.rb +7 -5
- data/lib/watir-webdriver/browser.rb +9 -2
- data/lib/watir-webdriver/browserbot.js +5 -2
- data/lib/watir-webdriver/container.rb +6 -9
- data/lib/watir-webdriver/{collections/element_collection.rb → element_collection.rb} +5 -0
- data/lib/watir-webdriver/elements/button.rb +5 -4
- data/lib/watir-webdriver/{element.rb → elements/element.rb} +29 -5
- data/lib/watir-webdriver/elements/file_field.rb +21 -4
- data/lib/watir-webdriver/elements/frame.rb +1 -1
- data/lib/watir-webdriver/elements/generated.rb +750 -750
- data/lib/watir-webdriver/elements/image.rb +6 -0
- data/lib/watir-webdriver/elements/link.rb +0 -4
- data/lib/watir-webdriver/elements/select.rb +22 -24
- data/lib/watir-webdriver/elements/table_row.rb +11 -1
- data/lib/watir-webdriver/elements/text_field.rb +5 -15
- data/lib/watir-webdriver/extensions/wait.rb +107 -0
- data/lib/watir-webdriver/html/generator.rb +1 -1
- data/lib/watir-webdriver/html/util.rb +1 -10
- data/lib/watir-webdriver/html/visitor.rb +2 -14
- data/lib/watir-webdriver/locators/button_locator.rb +22 -3
- data/lib/watir-webdriver/locators/element_locator.rb +54 -28
- data/lib/watir-webdriver/locators/table_row_locator.rb +3 -1
- data/lib/watir-webdriver/locators/text_field_locator.rb +7 -3
- data/lib/watir-webdriver/window_switching.rb +78 -0
- data/spec/browser_spec.rb +43 -0
- data/spec/container_spec.rb +43 -0
- data/spec/element_locator_spec.rb +305 -0
- data/spec/element_spec.rb +34 -5
- data/spec/html/closeable.html +13 -0
- data/spec/html/data_attributes.html +9 -0
- data/spec/html/wait.html +27 -0
- data/spec/html/window_switching.html +12 -0
- data/spec/input_spec.rb +14 -2
- data/spec/locator_spec_helper.rb +37 -0
- data/spec/spec_helper.rb +3 -0
- data/spec/wait_spec.rb +98 -0
- data/spec/watirspec/area_spec.rb +4 -4
- data/spec/watirspec/browser_spec.rb +37 -35
- data/spec/watirspec/button_spec.rb +22 -17
- data/spec/watirspec/buttons_spec.rb +1 -1
- data/spec/watirspec/checkbox_spec.rb +4 -0
- data/spec/watirspec/checkboxes_spec.rb +1 -1
- data/spec/watirspec/collections_spec.rb +4 -2
- data/spec/watirspec/dd_spec.rb +4 -0
- data/spec/watirspec/dds_spec.rb +1 -1
- data/spec/watirspec/del_spec.rb +4 -0
- data/spec/watirspec/dels_spec.rb +1 -1
- data/spec/watirspec/div_spec.rb +38 -12
- data/spec/watirspec/divs_spec.rb +1 -1
- data/spec/watirspec/dl_spec.rb +20 -6
- data/spec/watirspec/dls_spec.rb +1 -1
- data/spec/watirspec/dt_spec.rb +4 -0
- data/spec/watirspec/dts_spec.rb +1 -1
- data/spec/watirspec/em_spec.rb +4 -0
- data/spec/watirspec/ems_spec.rb +1 -1
- data/spec/watirspec/filefield_spec.rb +37 -2
- data/spec/watirspec/filefields_spec.rb +1 -1
- data/spec/watirspec/font_spec.rb +4 -0
- data/spec/watirspec/form_spec.rb +4 -0
- data/spec/watirspec/forms_spec.rb +6 -4
- data/spec/watirspec/frame_spec.rb +6 -0
- data/spec/watirspec/hidden_spec.rb +5 -4
- data/spec/watirspec/hiddens_spec.rb +1 -1
- data/spec/watirspec/hn_spec.rb +4 -0
- data/spec/watirspec/image_spec.rb +4 -0
- data/spec/watirspec/images_spec.rb +1 -1
- data/spec/watirspec/ins_spec.rb +4 -0
- data/spec/watirspec/inses_spec.rb +1 -1
- data/spec/watirspec/label_spec.rb +4 -0
- data/spec/watirspec/labels_spec.rb +2 -2
- data/spec/watirspec/li_spec.rb +4 -0
- data/spec/watirspec/link_spec.rb +15 -10
- data/spec/watirspec/links_spec.rb +6 -0
- data/spec/watirspec/lis_spec.rb +1 -1
- data/spec/watirspec/map_spec.rb +4 -0
- data/spec/watirspec/maps_spec.rb +1 -1
- data/spec/watirspec/meta_spec.rb +4 -0
- data/spec/watirspec/metas_spec.rb +1 -1
- data/spec/watirspec/ol_spec.rb +23 -9
- data/spec/watirspec/option_spec.rb +19 -7
- data/spec/watirspec/p_spec.rb +4 -0
- data/spec/watirspec/pre_spec.rb +4 -0
- data/spec/watirspec/pres_spec.rb +1 -1
- data/spec/watirspec/ps_spec.rb +1 -1
- data/spec/watirspec/radio_spec.rb +22 -13
- data/spec/watirspec/radios_spec.rb +6 -0
- data/spec/watirspec/select_list_spec.rb +29 -17
- data/spec/watirspec/select_lists_spec.rb +6 -0
- data/spec/watirspec/span_spec.rb +10 -2
- data/spec/watirspec/spans_spec.rb +1 -1
- data/spec/watirspec/strong_spec.rb +14 -4
- data/spec/watirspec/table_body_spec.rb +4 -0
- data/spec/watirspec/table_cell_spec.rb +9 -3
- data/spec/watirspec/table_cells_spec.rb +0 -1
- data/spec/watirspec/table_footer_spec.rb +4 -0
- data/spec/watirspec/table_header_spec.rb +4 -0
- data/spec/watirspec/table_row_spec.rb +15 -7
- data/spec/watirspec/table_rows_spec.rb +2 -2
- data/spec/watirspec/table_spec.rb +13 -7
- data/spec/watirspec/tables_spec.rb +1 -1
- data/spec/watirspec/text_field_spec.rb +21 -12
- data/spec/watirspec/text_fields_spec.rb +6 -0
- data/spec/watirspec/ul_spec.rb +4 -0
- data/spec/window_switching_spec.rb +116 -0
- data/watir-webdriver.gemspec +38 -16
- metadata +51 -27
- data/lib/watir-webdriver/collections/table_row_collection.rb +0 -11
@@ -31,6 +31,10 @@ describe "CheckBox" do
|
|
31
31
|
browser.checkbox(:xpath, "//input[@name='new_user_interests' and @value='cars']").set
|
32
32
|
end
|
33
33
|
|
34
|
+
it "returns the first checkbox if given no args" do
|
35
|
+
browser.checkbox.should exist
|
36
|
+
end
|
37
|
+
|
34
38
|
it "returns false if the checkbox button does not exist" do
|
35
39
|
browser.checkbox(:id, "no_such_id").should_not exist
|
36
40
|
browser.checkbox(:id, /no_such_id/).should_not exist
|
@@ -11,8 +11,10 @@ describe "Collections" do
|
|
11
11
|
browser.span(:id => "a_span").divs.size.should == 2
|
12
12
|
end
|
13
13
|
|
14
|
-
|
15
|
-
|
14
|
+
bug "http://code.google.com/p/selenium/issues/detail?id=695", [:webdriver, :ie] do
|
15
|
+
it "returns inner elements of parent element having same html tag" do
|
16
|
+
browser.span(:id => "a_span").spans.size.should == 2
|
17
|
+
end
|
16
18
|
end
|
17
19
|
|
18
20
|
end
|
data/spec/watirspec/dd_spec.rb
CHANGED
@@ -16,6 +16,10 @@ describe "Dd" do
|
|
16
16
|
browser.dd(:index, 0).should exist
|
17
17
|
end
|
18
18
|
|
19
|
+
it "returns the first dd if given no args" do
|
20
|
+
browser.dd.should exist
|
21
|
+
end
|
22
|
+
|
19
23
|
it "returns false if the element does not exist" do
|
20
24
|
browser.dd(:id, "no_such_id").should_not exist
|
21
25
|
end
|
data/spec/watirspec/dds_spec.rb
CHANGED
data/spec/watirspec/del_spec.rb
CHANGED
@@ -20,6 +20,10 @@ describe "Del" do
|
|
20
20
|
browser.del(:xpath, "//del[@id='lead']").should exist
|
21
21
|
end
|
22
22
|
|
23
|
+
it "returns the first del if given no args" do
|
24
|
+
browser.del.should exist
|
25
|
+
end
|
26
|
+
|
23
27
|
it "returns false if the element doesn't exist" do
|
24
28
|
browser.del(:id, "no_such_id").should_not exist
|
25
29
|
browser.del(:id, /no_such_id/).should_not exist
|
data/spec/watirspec/dels_spec.rb
CHANGED
data/spec/watirspec/div_spec.rb
CHANGED
@@ -22,6 +22,10 @@ describe "Div" do
|
|
22
22
|
browser.div(:xpath, "//div[@id='header']").should exist
|
23
23
|
end
|
24
24
|
|
25
|
+
it "returns the first div if given no args" do
|
26
|
+
browser.div.should exist
|
27
|
+
end
|
28
|
+
|
25
29
|
it "returns false if the element does not exist" do
|
26
30
|
browser.div(:id, "no_such_id").should_not exist
|
27
31
|
browser.div(:id, /no_such_id/).should_not exist
|
@@ -48,11 +52,11 @@ describe "Div" do
|
|
48
52
|
# Attribute methods
|
49
53
|
describe "#class_name" do
|
50
54
|
it "returns the class attribute if the element exists" do
|
51
|
-
browser.div(:id
|
55
|
+
browser.div(:id, "footer").class_name.should == "profile"
|
52
56
|
end
|
53
57
|
|
54
58
|
it "returns an empty string if the element exists but the attribute doesn't" do
|
55
|
-
browser.div(:id
|
59
|
+
browser.div(:id, "content").class_name.should == ""
|
56
60
|
end
|
57
61
|
|
58
62
|
it "raises UnknownObjectException if the element does not exist" do
|
@@ -85,8 +89,16 @@ describe "Div" do
|
|
85
89
|
end
|
86
90
|
|
87
91
|
describe "#style" do
|
88
|
-
|
89
|
-
|
92
|
+
not_compliant_on [:webdriver, :ie] do
|
93
|
+
it "returns the style attribute if the element exists" do
|
94
|
+
browser.div(:id, 'best_language').style.should == "color: red; text-decoration: underline; cursor: pointer;"
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
deviates_on [:webdriver, :ie] do
|
99
|
+
it "returns the style attribute if the element exists" do
|
100
|
+
browser.div(:id, 'best_language').style.should == "COLOR: red; CURSOR: pointer; TEXT-DECORATION: underline"
|
101
|
+
end
|
90
102
|
end
|
91
103
|
|
92
104
|
it "returns an empty string if the element exists but the attribute doesn't" do
|
@@ -181,14 +193,28 @@ describe "Div" do
|
|
181
193
|
end
|
182
194
|
|
183
195
|
describe "#html" do
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
196
|
+
not_compliant_on [:webdriver, :ie] do
|
197
|
+
it "returns the HTML of the element" do
|
198
|
+
html = browser.div(:id, 'footer').html.downcase
|
199
|
+
html.should include('id="footer"')
|
200
|
+
html.should include('title="closing remarks"')
|
201
|
+
html.should include('class="profile"')
|
202
|
+
|
203
|
+
html.should_not include('<div id="content">')
|
204
|
+
html.should_not include('</body>')
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
deviates_on [:webdriver, :ie] do
|
209
|
+
it "returns the HTML of the element" do
|
210
|
+
html = browser.div(:id, 'footer').html.downcase
|
211
|
+
html.should include('id=footer')
|
212
|
+
html.should include('title="closing remarks"')
|
213
|
+
html.should include('class=profile')
|
214
|
+
|
215
|
+
html.should_not include('<div id=content>')
|
216
|
+
html.should_not include('</body>')
|
217
|
+
end
|
192
218
|
end
|
193
219
|
end
|
194
220
|
|
data/spec/watirspec/divs_spec.rb
CHANGED
data/spec/watirspec/dl_spec.rb
CHANGED
@@ -16,6 +16,10 @@ describe "Dl" do
|
|
16
16
|
browser.dl(:index, 0).should exist
|
17
17
|
end
|
18
18
|
|
19
|
+
it "returns the first dl if given no args" do
|
20
|
+
browser.dl.should exist
|
21
|
+
end
|
22
|
+
|
19
23
|
it "returns false if the element does not exist" do
|
20
24
|
browser.dl(:id, "no_such_id").should_not exist
|
21
25
|
end
|
@@ -32,11 +36,11 @@ describe "Dl" do
|
|
32
36
|
# Attribute methods
|
33
37
|
describe "#class_name" do
|
34
38
|
it "returns the class attribute if the element exists" do
|
35
|
-
browser.dl(:id
|
39
|
+
browser.dl(:id, "experience-list").class_name.should == "list"
|
36
40
|
end
|
37
41
|
|
38
42
|
it "returns an empty string if the element exists but the attribute doesn't" do
|
39
|
-
browser.dl(:id
|
43
|
+
browser.dl(:id, "noop").class_name.should == ""
|
40
44
|
end
|
41
45
|
|
42
46
|
it "raises UnknownObjectException if the element does not exist" do
|
@@ -113,10 +117,20 @@ describe "Dl" do
|
|
113
117
|
end
|
114
118
|
|
115
119
|
describe "#html" do
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
+
not_compliant_on [:webdriver, :ie] do
|
121
|
+
it "returns the HTML of the element" do
|
122
|
+
html = browser.dl(:id, 'experience-list').html.downcase
|
123
|
+
html.should include('<dt class="current-industry">')
|
124
|
+
html.should_not include('</body>')
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
deviates_on [:webdriver, :ie] do
|
129
|
+
it "returns the HTML of the element" do
|
130
|
+
html = browser.dl(:id, 'experience-list').html.downcase
|
131
|
+
html.should include('<dt class=current-industry>')
|
132
|
+
html.should_not include('</body>')
|
133
|
+
end
|
120
134
|
end
|
121
135
|
end
|
122
136
|
|
data/spec/watirspec/dls_spec.rb
CHANGED
data/spec/watirspec/dt_spec.rb
CHANGED
@@ -16,6 +16,10 @@ describe "Dt" do
|
|
16
16
|
browser.dt(:index, 0).should exist
|
17
17
|
end
|
18
18
|
|
19
|
+
it "returns the first dt if given no args" do
|
20
|
+
browser.dt.should exist
|
21
|
+
end
|
22
|
+
|
19
23
|
it "returns false if the element does not exist" do
|
20
24
|
browser.dt(:id, "no_such_id").should_not exist
|
21
25
|
end
|
data/spec/watirspec/dts_spec.rb
CHANGED
data/spec/watirspec/em_spec.rb
CHANGED
@@ -16,6 +16,10 @@ describe "Em" do
|
|
16
16
|
browser.em(:index, 0).should exist
|
17
17
|
end
|
18
18
|
|
19
|
+
it "returns the first em if given no args" do
|
20
|
+
browser.em.should exist
|
21
|
+
end
|
22
|
+
|
19
23
|
it "returns false if the element does not exist" do
|
20
24
|
browser.em(:id, "no_such_id").should_not exist
|
21
25
|
end
|
data/spec/watirspec/ems_spec.rb
CHANGED
@@ -19,6 +19,10 @@ describe "FileField" do
|
|
19
19
|
browser.file_field(:xpath, "//input[@id='new_user_portrait']").should exist
|
20
20
|
end
|
21
21
|
|
22
|
+
it "returns the first file field if given no args" do
|
23
|
+
browser.file_field.should exist
|
24
|
+
end
|
25
|
+
|
22
26
|
it "returns false if the file field doesn't exist" do
|
23
27
|
browser.file_field(:id, 'no_such_id').should_not exist
|
24
28
|
browser.file_field(:id, /no_such_id/).should_not exist
|
@@ -107,10 +111,41 @@ describe "FileField" do
|
|
107
111
|
path = File.expand_path(__FILE__)
|
108
112
|
|
109
113
|
browser.file_field(:name, "new_user_portrait").set path
|
110
|
-
browser.file_field(:name, "new_user_portrait").value.should
|
111
|
-
messages.first.should include(File.basename(path))
|
114
|
+
browser.file_field(:name, "new_user_portrait").value.should include(File.basename(path)) # only some browser will return the full path
|
115
|
+
messages.first.should include(File.basename(path))
|
116
|
+
browser.button(:name, "new_user_submit").click
|
117
|
+
end
|
118
|
+
|
119
|
+
it "raises an error if the file does not exist" do
|
120
|
+
lambda {
|
121
|
+
browser.file_field.set('/tmp/unlikely-to-exist')
|
122
|
+
}.should raise_error(Errno::ENOENT)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
|
127
|
+
describe "#value=" do
|
128
|
+
it "is able to set a file path in the field and click the upload button and fire the onchange event" do
|
129
|
+
browser.goto("#{WatirSpec.host}/forms_with_input_elements.html")
|
130
|
+
|
131
|
+
path = File.expand_path(__FILE__)
|
132
|
+
|
133
|
+
browser.file_field(:name, "new_user_portrait").value = path
|
134
|
+
browser.file_field(:name, "new_user_portrait").value.should include(File.basename(path)) # only some browser will return the full path
|
135
|
+
messages.first.should include(File.basename(path))
|
112
136
|
browser.button(:name, "new_user_submit").click
|
113
137
|
end
|
138
|
+
|
139
|
+
it "does not raise an error if the file does not exist" do
|
140
|
+
browser.file_field.value = '/tmp/unlikely-to-exist'
|
141
|
+
browser.file_field.value.should == '/tmp/unlikely-to-exist'
|
142
|
+
end
|
143
|
+
|
144
|
+
it "does not alter its argument" do
|
145
|
+
value = '/foo/bar'
|
146
|
+
browser.file_field.value = value
|
147
|
+
value.should == '/foo/bar'
|
148
|
+
end
|
114
149
|
end
|
115
150
|
|
116
151
|
end
|
data/spec/watirspec/font_spec.rb
CHANGED
data/spec/watirspec/form_spec.rb
CHANGED
@@ -23,6 +23,10 @@ describe "Form" do
|
|
23
23
|
browser.form(:xpath, "//form[@id='new_user']").should exist
|
24
24
|
end
|
25
25
|
|
26
|
+
it "returns the first form if given no args" do
|
27
|
+
browser.form.should exist
|
28
|
+
end
|
29
|
+
|
26
30
|
it "returns false if the form doesn't exist" do
|
27
31
|
browser.form(:id, 'no_such_id').should_not exist
|
28
32
|
browser.form(:id, /no_such_id/).should_not exist
|
@@ -14,9 +14,11 @@ describe "Forms" do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
describe "#[]n" do
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
bug "http://github.com/jarib/watir-webdriver/issues/issue/27", [:webdriver, :firefox], [:webdriver, :ie] do
|
18
|
+
it "provides access to the nth form" do
|
19
|
+
browser.forms[0].action.should == 'post_to_me'
|
20
|
+
browser.forms[0].attribute_value('method').should == 'post'
|
21
|
+
end
|
20
22
|
end
|
21
23
|
end
|
22
24
|
|
@@ -29,7 +31,7 @@ describe "Forms" do
|
|
29
31
|
f.id.should == browser.form(:index, index).id
|
30
32
|
f.class_name.should == browser.form(:index, index).class_name
|
31
33
|
|
32
|
-
|
34
|
+
count += 1
|
33
35
|
end
|
34
36
|
|
35
37
|
count.should > 0
|
@@ -45,6 +45,12 @@ describe "Frame" do
|
|
45
45
|
browser.frame(:xpath, "//iframe[@id='frame_1']").should exist
|
46
46
|
end
|
47
47
|
|
48
|
+
bug "http://github.com/jarib/watir-webdriver/issues#issue/17", :webdriver do
|
49
|
+
it "returns the first frame if given no args" do
|
50
|
+
browser.frame.should exist
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
48
54
|
it "returns false if the frame doesn't exist" do
|
49
55
|
browser.frame(:id, "no_such_id").should_not exist
|
50
56
|
browser.frame(:name, "no_such_text").should_not exist
|
@@ -16,14 +16,15 @@ describe "Hidden" do
|
|
16
16
|
browser.hidden(:name, /new_user_interests/).should exist
|
17
17
|
browser.hidden(:value, 'dolls').should exist
|
18
18
|
browser.hidden(:value, /dolls/).should exist
|
19
|
-
# TODO: figure out what :text means for Hidden
|
20
|
-
# browser.hidden(:text, 'dolls').should exist
|
21
|
-
# browser.hidden(:text, /dolls/).should exist
|
22
19
|
browser.hidden(:class, 'fun').should exist
|
23
20
|
browser.hidden(:class, /fun/).should exist
|
24
21
|
browser.hidden(:index, 0).should exist
|
25
22
|
browser.hidden(:xpath, "//input[@id='new_user_interests_dolls']").should exist
|
26
|
-
|
23
|
+
end
|
24
|
+
|
25
|
+
it "returns the first hidden if given no args" do
|
26
|
+
browser.hidden.should exist
|
27
|
+
end
|
27
28
|
|
28
29
|
it "returns false if the element does not exist" do
|
29
30
|
browser.hidden(:id, 'no_such_id').should_not exist
|
data/spec/watirspec/hn_spec.rb
CHANGED
@@ -19,6 +19,10 @@ describe "H1", "H2", "H3", "H4", "H5", "H6" do
|
|
19
19
|
browser.h1(:xpath, "//h1[@id='first_header']").should exist
|
20
20
|
end
|
21
21
|
|
22
|
+
it "returns the first h1 if given no args" do
|
23
|
+
browser.h1.should exist
|
24
|
+
end
|
25
|
+
|
22
26
|
it "returns true if the element exists" do
|
23
27
|
browser.h1(:id, "no_such_id").should_not exist
|
24
28
|
browser.h1(:id, /no_such_id/).should_not exist
|