watir-webdriver 0.1.4 → 0.1.5
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/.gitignore +9 -0
- data/Gemfile +3 -3
- data/Rakefile +3 -28
- data/lib/watir-webdriver.rb +1 -0
- data/lib/watir-webdriver/version.rb +3 -0
- data/watir-webdriver.gemspec +23 -247
- metadata +34 -326
- data/VERSION +0 -1
- data/spec/watirspec/area_spec.rb +0 -77
- data/spec/watirspec/areas_spec.rb +0 -45
- data/spec/watirspec/browser_spec.rb +0 -274
- data/spec/watirspec/button_spec.rb +0 -255
- data/spec/watirspec/buttons_spec.rb +0 -58
- data/spec/watirspec/checkbox_spec.rb +0 -276
- data/spec/watirspec/checkboxes_spec.rb +0 -47
- data/spec/watirspec/collections_spec.rb +0 -20
- data/spec/watirspec/dd_spec.rb +0 -127
- data/spec/watirspec/dds_spec.rb +0 -45
- data/spec/watirspec/del_spec.rb +0 -145
- data/spec/watirspec/dels_spec.rb +0 -45
- data/spec/watirspec/div_spec.rb +0 -221
- data/spec/watirspec/divs_spec.rb +0 -45
- data/spec/watirspec/dl_spec.rb +0 -137
- data/spec/watirspec/dls_spec.rb +0 -46
- data/spec/watirspec/dt_spec.rb +0 -127
- data/spec/watirspec/dts_spec.rb +0 -45
- data/spec/watirspec/element_spec.rb +0 -149
- data/spec/watirspec/em_spec.rb +0 -101
- data/spec/watirspec/ems_spec.rb +0 -46
- data/spec/watirspec/filefield_spec.rb +0 -156
- data/spec/watirspec/filefields_spec.rb +0 -46
- data/spec/watirspec/font_spec.rb +0 -32
- data/spec/watirspec/form_spec.rb +0 -63
- data/spec/watirspec/forms_spec.rb +0 -47
- data/spec/watirspec/frame_spec.rb +0 -144
- data/spec/watirspec/frames_spec.rb +0 -83
- data/spec/watirspec/hidden_spec.rb +0 -103
- data/spec/watirspec/hiddens_spec.rb +0 -46
- data/spec/watirspec/hn_spec.rb +0 -97
- data/spec/watirspec/hns_spec.rb +0 -42
- data/spec/watirspec/image_spec.rb +0 -208
- data/spec/watirspec/images_spec.rb +0 -45
- data/spec/watirspec/ins_spec.rb +0 -146
- data/spec/watirspec/inses_spec.rb +0 -45
- data/spec/watirspec/label_spec.rb +0 -81
- data/spec/watirspec/labels_spec.rb +0 -45
- data/spec/watirspec/li_spec.rb +0 -116
- data/spec/watirspec/lib/guards.rb +0 -59
- data/spec/watirspec/lib/implementation.rb +0 -48
- data/spec/watirspec/lib/runner.rb +0 -83
- data/spec/watirspec/lib/server.rb +0 -194
- data/spec/watirspec/lib/watirspec.rb +0 -75
- data/spec/watirspec/link_spec.rb +0 -174
- data/spec/watirspec/links_spec.rb +0 -49
- data/spec/watirspec/lis_spec.rb +0 -45
- data/spec/watirspec/map_spec.rb +0 -80
- data/spec/watirspec/maps_spec.rb +0 -46
- data/spec/watirspec/meta_spec.rb +0 -24
- data/spec/watirspec/metas_spec.rb +0 -43
- data/spec/watirspec/ol_spec.rb +0 -90
- data/spec/watirspec/ols_spec.rb +0 -45
- data/spec/watirspec/option_spec.rb +0 -152
- data/spec/watirspec/p_spec.rb +0 -132
- data/spec/watirspec/pre_spec.rb +0 -116
- data/spec/watirspec/pres_spec.rb +0 -45
- data/spec/watirspec/ps_spec.rb +0 -45
- data/spec/watirspec/radio_spec.rb +0 -262
- data/spec/watirspec/radios_spec.rb +0 -46
- data/spec/watirspec/select_list_spec.rb +0 -335
- data/spec/watirspec/select_lists_spec.rb +0 -49
- data/spec/watirspec/span_spec.rb +0 -146
- data/spec/watirspec/spans_spec.rb +0 -45
- data/spec/watirspec/spec_helper.rb +0 -20
- data/spec/watirspec/strong_spec.rb +0 -93
- data/spec/watirspec/strongs_spec.rb +0 -46
- data/spec/watirspec/table_nesting_spec.rb +0 -50
- data/spec/watirspec/table_spec.rb +0 -150
- data/spec/watirspec/tables_spec.rb +0 -47
- data/spec/watirspec/tbody_spec.rb +0 -97
- data/spec/watirspec/tbodys_spec.rb +0 -65
- data/spec/watirspec/td_spec.rb +0 -72
- data/spec/watirspec/tds_spec.rb +0 -60
- data/spec/watirspec/text_field_spec.rb +0 -283
- data/spec/watirspec/text_fields_spec.rb +0 -49
- data/spec/watirspec/tfoot_spec.rb +0 -92
- data/spec/watirspec/tfoots_spec.rb +0 -71
- data/spec/watirspec/thead_spec.rb +0 -92
- data/spec/watirspec/theads_spec.rb +0 -71
- data/spec/watirspec/tr_spec.rb +0 -88
- data/spec/watirspec/trs_spec.rb +0 -68
- data/spec/watirspec/ul_spec.rb +0 -80
- data/spec/watirspec/uls_spec.rb +0 -44
- data/spec/watirspec/window_switching_spec.rb +0 -164
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.1.4
|
data/spec/watirspec/area_spec.rb
DELETED
@@ -1,77 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require File.expand_path("../spec_helper", __FILE__)
|
3
|
-
|
4
|
-
describe "Area" 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 area exists" do
|
13
|
-
browser.area(:id, "NCE").should exist
|
14
|
-
browser.area(:id, /NCE/).should exist
|
15
|
-
browser.area(:title, "Tables").should exist
|
16
|
-
browser.area(:title, /Tables/).should exist
|
17
|
-
|
18
|
-
not_compliant_on [:webdriver, :ie] do
|
19
|
-
browser.area(:href, "tables.html").should exist
|
20
|
-
end
|
21
|
-
|
22
|
-
browser.area(:href, /tables/).should exist
|
23
|
-
|
24
|
-
browser.area(:index, 0).should exist
|
25
|
-
browser.area(:xpath, "//area[@id='NCE']").should exist
|
26
|
-
end
|
27
|
-
|
28
|
-
it "returns the first area if given no args" do
|
29
|
-
browser.area.should exist
|
30
|
-
end
|
31
|
-
|
32
|
-
it "returns false if the area doesn't exist" do
|
33
|
-
browser.area(:id, "no_such_id").should_not exist
|
34
|
-
browser.area(:id, /no_such_id/).should_not exist
|
35
|
-
browser.area(:title, "no_such_title").should_not exist
|
36
|
-
browser.area(:title, /no_such_title/).should_not exist
|
37
|
-
|
38
|
-
browser.area(:href, "no-tables.html").should_not exist
|
39
|
-
browser.area(:href, /no-tables/).should_not exist
|
40
|
-
|
41
|
-
browser.area(:index, 1337).should_not exist
|
42
|
-
browser.area(:xpath, "//area[@id='no_such_id']").should_not exist
|
43
|
-
end
|
44
|
-
|
45
|
-
it "raises TypeError when 'what' argument is invalid" do
|
46
|
-
lambda { browser.area(:id, 3.14).exists? }.should raise_error(TypeError)
|
47
|
-
end
|
48
|
-
|
49
|
-
it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
50
|
-
lambda { browser.area(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
# Attribute methods
|
55
|
-
describe "#id" do
|
56
|
-
it "returns the id attribute" do
|
57
|
-
browser.area(:index, 0).id.should == "NCE"
|
58
|
-
end
|
59
|
-
|
60
|
-
it "returns an empty string if the element exists and the attribute doesn't" do
|
61
|
-
browser.area(:index, 2).id.should == ''
|
62
|
-
end
|
63
|
-
|
64
|
-
it "raises UnknownObjectException if the area doesn't exist" do
|
65
|
-
lambda { browser.area(:id, "no_such_id").id }.should raise_error(UnknownObjectException)
|
66
|
-
lambda { browser.area(:index, 1337).id }.should raise_error(UnknownObjectException)
|
67
|
-
end
|
68
|
-
|
69
|
-
end
|
70
|
-
|
71
|
-
describe "#respond_to?" do
|
72
|
-
it "returns true for all attribute methods" do
|
73
|
-
browser.area(:index, 0).should respond_to(:id)
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require File.expand_path("../spec_helper", __FILE__)
|
3
|
-
|
4
|
-
describe "Areas" do
|
5
|
-
|
6
|
-
before :each do
|
7
|
-
browser.goto(WatirSpec.files + "/images.html")
|
8
|
-
end
|
9
|
-
|
10
|
-
bug "http://github.com/jarib/celerity/issues#issue/25", :celerity do
|
11
|
-
describe "with selectors" do
|
12
|
-
it "returns the matching elements" do
|
13
|
-
browser.areas(:alt => "Tables").to_a.should == [browser.area(:alt => "Tables")]
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
describe "#length" do
|
19
|
-
it "returns the number of areas" do
|
20
|
-
browser.areas.length.should == 3
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe "#[]" do
|
25
|
-
it "returns the area at the given index" do
|
26
|
-
browser.areas[0].id.should == "NCE"
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
describe "#each" do
|
31
|
-
it "iterates through areas correctly" do
|
32
|
-
count = 0
|
33
|
-
|
34
|
-
browser.areas.each_with_index do |a, index|
|
35
|
-
a.id.should == browser.area(:index, index).id
|
36
|
-
a.title.should == browser.area(:index, index).title
|
37
|
-
|
38
|
-
count += 1
|
39
|
-
end
|
40
|
-
|
41
|
-
count.should > 0
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|
@@ -1,274 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require File.expand_path("../spec_helper", __FILE__)
|
3
|
-
|
4
|
-
describe "Browser" do
|
5
|
-
|
6
|
-
describe "#exists?" do
|
7
|
-
it "returns true if we are at a page" do
|
8
|
-
browser.goto(WatirSpec.files + "/non_control_elements.html")
|
9
|
-
browser.should exist
|
10
|
-
end
|
11
|
-
|
12
|
-
bug "http://github.com/jarib/watir-webdriver/issues/issue/29", [:webdriver, :ie] do
|
13
|
-
it "returns false after Browser#close" do
|
14
|
-
b = WatirSpec.new_browser
|
15
|
-
b.close
|
16
|
-
b.should_not exist
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
# this should be rewritten - the actual string returned varies alot between implementations
|
22
|
-
describe "#html" do
|
23
|
-
not_compliant_on [:webdriver, :ie] do
|
24
|
-
it "returns the DOM of the page as an HTML string" do
|
25
|
-
browser.goto(WatirSpec.files + "/right_click.html")
|
26
|
-
html = browser.html.downcase # varies between browsers
|
27
|
-
|
28
|
-
html.should =~ /^<html/
|
29
|
-
html.should include('<meta content="text/html; charset=utf-8" http-equiv="content-type" />')
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
deviates_on [:webdriver, :ie] do
|
34
|
-
it "returns the DOM of the page as an HTML string" do
|
35
|
-
browser.goto(WatirSpec.files + "/right_click.html")
|
36
|
-
html = browser.html.downcase # varies between browsers
|
37
|
-
|
38
|
-
html.should =~ /^<html/
|
39
|
-
html.should include('<meta content="text/html; charset=utf-8" http-equiv=content-type>')
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
describe "#title" do
|
45
|
-
it "returns the current page title" do
|
46
|
-
browser.goto(WatirSpec.files + "/non_control_elements.html")
|
47
|
-
browser.title.should == "Non-control elements"
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
describe "#status" do
|
52
|
-
not_compliant_on :webdriver do # need to set Firefox preference, might do this when selenium-webdriver exposes the profile used
|
53
|
-
it "returns the current value of window.status" do
|
54
|
-
browser.goto(WatirSpec.files + "/non_control_elements.html")
|
55
|
-
|
56
|
-
# for firefox, this needs to be enabled in
|
57
|
-
# Preferences -> Content -> Advanced -> Change status bar text
|
58
|
-
browser.execute_script "window.status = 'All done!';"
|
59
|
-
browser.status.should == "All done!"
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
describe "#text" do
|
65
|
-
it "returns the text of the page" do
|
66
|
-
browser.goto(WatirSpec.files + "/non_control_elements.html")
|
67
|
-
browser.text.should include("Dubito, ergo cogito, ergo sum.")
|
68
|
-
end
|
69
|
-
|
70
|
-
it "returns the text also if the content-type is text/plain" do
|
71
|
-
# more specs for text/plain? what happens if we call other methods?
|
72
|
-
browser.goto(WatirSpec.host + "/plain_text")
|
73
|
-
browser.text.strip.should == 'This is text/plain'
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
describe "#url" do
|
78
|
-
it "returns the current url" do
|
79
|
-
browser.goto(WatirSpec.host + "/non_control_elements.html")
|
80
|
-
browser.url.should == WatirSpec.host + "/non_control_elements.html"
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
bug "http://github.com/jarib/watirspec/issues/issue/8", [:webdriver, :ie], [:webdriver, :chrome] do
|
85
|
-
describe ".start" do
|
86
|
-
it "goes to the given URL and return an instance of itself" do
|
87
|
-
browser = WatirSpec.implementation.browser_class.start("#{WatirSpec.files}/non_control_elements.html")
|
88
|
-
browser.should be_instance_of(WatirSpec.implementation.browser_class)
|
89
|
-
browser.title.should == "Non-control elements"
|
90
|
-
browser.close
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
describe "#goto" do
|
96
|
-
it "adds http:// to URLs with no URL scheme specified" do
|
97
|
-
url = WatirSpec.host[%r{http://(.*)}, 1]
|
98
|
-
url.should_not be_nil
|
99
|
-
browser.goto(url)
|
100
|
-
browser.url.should =~ %r[http://#{url}/?]
|
101
|
-
end
|
102
|
-
|
103
|
-
it "goes to the given url without raising errors" do
|
104
|
-
lambda { browser.goto(WatirSpec.files + "/non_control_elements.html") }.should_not raise_error
|
105
|
-
end
|
106
|
-
|
107
|
-
it "updates the page when location is changed with setTimeout + window.location" do
|
108
|
-
browser.goto(WatirSpec.files + "/timeout_window_location.html")
|
109
|
-
sleep 1
|
110
|
-
browser.url.should include("non_control_elements.html")
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
describe "#refresh" do
|
115
|
-
not_compliant_on [:webdriver, :ie] do
|
116
|
-
it "refreshes the page" do
|
117
|
-
browser.goto(WatirSpec.files + "/non_control_elements.html")
|
118
|
-
browser.span(:class, 'footer').click
|
119
|
-
browser.span(:class, 'footer').text.should include('Javascript')
|
120
|
-
browser.refresh
|
121
|
-
browser.span(:class, 'footer').text.should_not include('Javascript')
|
122
|
-
end
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
describe "#execute_script" do
|
127
|
-
it "executes the given JavaScript on the current page" do
|
128
|
-
browser.goto(WatirSpec.files + "/non_control_elements.html")
|
129
|
-
browser.pre(:id, 'rspec').text.should_not == "javascript text"
|
130
|
-
browser.execute_script("document.getElementById('rspec').innerHTML = 'javascript text'")
|
131
|
-
browser.pre(:id, 'rspec').text.should == "javascript text"
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
describe "#back and #forward" do
|
136
|
-
it "goes to the previous page" do
|
137
|
-
browser.goto("#{WatirSpec.host}/non_control_elements.html")
|
138
|
-
orig_url = browser.url
|
139
|
-
browser.goto("#{WatirSpec.host}/tables.html")
|
140
|
-
new_url = browser.url
|
141
|
-
orig_url.should_not == new_url
|
142
|
-
browser.back
|
143
|
-
orig_url.should == browser.url
|
144
|
-
end
|
145
|
-
|
146
|
-
it "goes to the next page" do
|
147
|
-
urls = []
|
148
|
-
browser.goto(WatirSpec.host + "/non_control_elements.html")
|
149
|
-
urls << browser.url
|
150
|
-
browser.goto(WatirSpec.host + "/tables.html")
|
151
|
-
urls << browser.url
|
152
|
-
|
153
|
-
browser.back
|
154
|
-
browser.url.should == urls.first
|
155
|
-
browser.forward
|
156
|
-
browser.url.should == urls.last
|
157
|
-
end
|
158
|
-
|
159
|
-
it "navigates between several history items" do
|
160
|
-
urls = [ "#{WatirSpec.host}/non_control_elements.html",
|
161
|
-
"#{WatirSpec.host}/tables.html",
|
162
|
-
"#{WatirSpec.host}/forms_with_input_elements.html",
|
163
|
-
"#{WatirSpec.host}/definition_lists.html"
|
164
|
-
].map do |page|
|
165
|
-
browser.goto page
|
166
|
-
browser.url
|
167
|
-
end
|
168
|
-
|
169
|
-
3.times { browser.back }
|
170
|
-
browser.url.should == urls.first
|
171
|
-
2.times { browser.forward }
|
172
|
-
browser.url.should == urls[2]
|
173
|
-
end
|
174
|
-
end
|
175
|
-
|
176
|
-
describe "#element_by_xpath" do
|
177
|
-
before :each do
|
178
|
-
browser.goto(WatirSpec.files + "/forms_with_input_elements.html")
|
179
|
-
end
|
180
|
-
|
181
|
-
it "finds submit buttons matching the given xpath" do
|
182
|
-
browser.element_by_xpath("//input[@type='submit']").should exist
|
183
|
-
end
|
184
|
-
|
185
|
-
it "finds reset buttons matching the given xpath" do
|
186
|
-
browser.element_by_xpath("//input[@type='reset']").should exist
|
187
|
-
end
|
188
|
-
|
189
|
-
it "finds image buttons matching the given xpath" do
|
190
|
-
browser.element_by_xpath("//input[@type='image']").should exist
|
191
|
-
end
|
192
|
-
|
193
|
-
it "finds the element matching the given xpath" do
|
194
|
-
browser.element_by_xpath("//input[@type='password']").should exist
|
195
|
-
end
|
196
|
-
|
197
|
-
it "will not find elements that doesn't exist" do
|
198
|
-
e = browser.element_by_xpath("//input[@type='foobar']")
|
199
|
-
e.should_not exist
|
200
|
-
lambda { e.text }.should raise_error(UnknownObjectException)
|
201
|
-
end
|
202
|
-
end
|
203
|
-
|
204
|
-
describe "#elements_by_xpath" do
|
205
|
-
before :each do
|
206
|
-
browser.goto(WatirSpec.files + "/forms_with_input_elements.html")
|
207
|
-
end
|
208
|
-
|
209
|
-
not_compliant_on [:webdriver, :ie], :celerity do
|
210
|
-
it "returns an Array of matching elements" do
|
211
|
-
objects = browser.elements_by_xpath("//*[@type='text']")
|
212
|
-
objects.should be_kind_of(Array)
|
213
|
-
|
214
|
-
objects.size.should == 5
|
215
|
-
end
|
216
|
-
end
|
217
|
-
|
218
|
-
deviates_on [:webdriver, :ie], :celerity do
|
219
|
-
it "returns an Array of matching elements" do
|
220
|
-
objects = browser.elements_by_xpath("//*[@type='text']")
|
221
|
-
objects.should be_kind_of(Array)
|
222
|
-
|
223
|
-
objects.size.should == 6
|
224
|
-
end
|
225
|
-
end
|
226
|
-
|
227
|
-
it "returns an empty Array if there are no matching elements" do
|
228
|
-
objects = browser.elements_by_xpath("//*[@type='foobar']")
|
229
|
-
objects.should be_kind_of(Array)
|
230
|
-
objects.size.should == 0
|
231
|
-
end
|
232
|
-
end
|
233
|
-
|
234
|
-
describe "#add_checker" do
|
235
|
-
it "raises ArgumentError when not given any arguments" do
|
236
|
-
lambda { browser.add_checker }.should raise_error(ArgumentError)
|
237
|
-
end
|
238
|
-
|
239
|
-
it "runs the given proc on each page load" do
|
240
|
-
output = ''
|
241
|
-
proc = Proc.new { |browser| output << browser.text }
|
242
|
-
|
243
|
-
begin
|
244
|
-
browser.add_checker(proc)
|
245
|
-
browser.goto(WatirSpec.files + "/non_control_elements.html")
|
246
|
-
|
247
|
-
output.should include('Dubito, ergo cogito, ergo sum')
|
248
|
-
ensure
|
249
|
-
browser.disable_checker(proc)
|
250
|
-
end
|
251
|
-
end
|
252
|
-
end
|
253
|
-
|
254
|
-
describe "#disable_checker" do
|
255
|
-
it "removes a previously added checker" do
|
256
|
-
output = ''
|
257
|
-
checker = lambda { |browser| output << browser.text }
|
258
|
-
|
259
|
-
browser.add_checker(checker)
|
260
|
-
browser.goto(WatirSpec.files + "/non_control_elements.html")
|
261
|
-
output.should include('Dubito, ergo cogito, ergo sum')
|
262
|
-
|
263
|
-
browser.disable_checker(checker)
|
264
|
-
browser.goto(WatirSpec.files + "/definition_lists.html")
|
265
|
-
output.should_not include('definition_lists')
|
266
|
-
end
|
267
|
-
end
|
268
|
-
|
269
|
-
it "raises UnknownObjectException when trying to access DOM elements on plain/text-page" do
|
270
|
-
browser.goto(WatirSpec.host + "/plain_text")
|
271
|
-
lambda { browser.div(:id, 'foo').id }.should raise_error(UnknownObjectException)
|
272
|
-
end
|
273
|
-
|
274
|
-
end
|
@@ -1,255 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require File.expand_path("../spec_helper", __FILE__)
|
3
|
-
|
4
|
-
describe "Button" 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 button exists" do
|
13
|
-
browser.button(:id, "new_user_submit").should exist
|
14
|
-
browser.button(:id, /new_user_submit/).should exist
|
15
|
-
browser.button(:name, "new_user_reset").should exist
|
16
|
-
browser.button(:name, /new_user_reset/).should exist
|
17
|
-
browser.button(:value, "Button 2").should exist
|
18
|
-
browser.button(:value, /Button 2/).should exist
|
19
|
-
not_compliant_on [:webdriver, :ie] do
|
20
|
-
browser.button(:src, "images/button.jpg").should exist
|
21
|
-
end
|
22
|
-
browser.button(:src, /button.jpg/).should exist
|
23
|
-
browser.button(:text, "Button 2").should exist
|
24
|
-
browser.button(:text, /Button 2/).should exist
|
25
|
-
browser.button(:class, "image").should exist
|
26
|
-
browser.button(:class, /image/).should exist
|
27
|
-
browser.button(:index, 0).should exist
|
28
|
-
browser.button(:xpath, "//input[@id='new_user_submit']").should exist
|
29
|
-
browser.button(:alt, "Create a new user").should exist
|
30
|
-
browser.button(:alt, /Create a/).should exist
|
31
|
-
end
|
32
|
-
|
33
|
-
it "returns true if the button exists (how = :caption)" do
|
34
|
-
browser.button(:caption, "Button 2").should exist
|
35
|
-
browser.button(:caption, /Button 2/).should exist
|
36
|
-
end
|
37
|
-
|
38
|
-
|
39
|
-
it "returns the first button if given no args" do
|
40
|
-
browser.button.should exist
|
41
|
-
end
|
42
|
-
|
43
|
-
it "returns false if the button doesn't exist" do
|
44
|
-
browser.button(:id, "no_such_id").should_not exist
|
45
|
-
browser.button(:id, /no_such_id/).should_not exist
|
46
|
-
browser.button(:name, "no_such_name").should_not exist
|
47
|
-
browser.button(:name, /no_such_name/).should_not exist
|
48
|
-
browser.button(:value, "no_such_value").should_not exist
|
49
|
-
browser.button(:value, /no_such_value/).should_not exist
|
50
|
-
browser.button(:src, "no_such_src").should_not exist
|
51
|
-
browser.button(:src, /no_such_src/).should_not exist
|
52
|
-
browser.button(:text, "no_such_text").should_not exist
|
53
|
-
browser.button(:text, /no_such_text/).should_not exist
|
54
|
-
browser.button(:class, "no_such_class").should_not exist
|
55
|
-
browser.button(:class, /no_such_class/).should_not exist
|
56
|
-
browser.button(:index, 1337).should_not exist
|
57
|
-
browser.button(:xpath, "//input[@id='no_such_id']").should_not exist
|
58
|
-
end
|
59
|
-
|
60
|
-
it "checks the tag name and type attribute when locating by xpath" do
|
61
|
-
browser.button(:xpath, "//input[@type='text']").should_not exist
|
62
|
-
browser.button(:xpath, "//input[@type='button']").should exist
|
63
|
-
end
|
64
|
-
|
65
|
-
it "raises TypeError when 'what' argument is invalid" do
|
66
|
-
lambda { browser.button(:id, 3.14).exists? }.should raise_error(TypeError)
|
67
|
-
end
|
68
|
-
|
69
|
-
it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
70
|
-
lambda { browser.button(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
# Attribute methods
|
75
|
-
describe "#class_name" do
|
76
|
-
it "returns the class name of the button" do
|
77
|
-
browser.button(:name, "new_user_image").class_name.should == "image"
|
78
|
-
end
|
79
|
-
|
80
|
-
it "returns an empty string if the button has no class name" do
|
81
|
-
browser.button(:name, "new_user_submit").class_name.should == ""
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
describe "#id" do
|
86
|
-
it "returns the id if the button exists" do
|
87
|
-
browser.button(:index, 0).id.should == 'new_user_submit'
|
88
|
-
browser.button(:index, 1).id.should == 'new_user_reset'
|
89
|
-
browser.button(:index, 2).id.should == 'new_user_button'
|
90
|
-
end
|
91
|
-
|
92
|
-
it "raises UnknownObjectException if button does not exist" do
|
93
|
-
lambda { browser.button(:index, 1337).id }.should raise_error(UnknownObjectException)
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
describe "#name" do
|
98
|
-
it "returns the name if button exists" do
|
99
|
-
browser.button(:index, 0).name.should == 'new_user_submit'
|
100
|
-
browser.button(:index, 1).name.should == 'new_user_reset'
|
101
|
-
browser.button(:index, 2).name.should == 'new_user_button'
|
102
|
-
end
|
103
|
-
|
104
|
-
it "raises UnknownObjectException if the button does not exist" do
|
105
|
-
lambda { browser.button(:name, "no_such_name").name }.should raise_error(UnknownObjectException)
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
describe "#src" do
|
110
|
-
it "returns the src attribute for the button image" do
|
111
|
-
# varies between browsers
|
112
|
-
browser.button(:name, "new_user_image").src.should =~ %r"images/button.jpg$"
|
113
|
-
end
|
114
|
-
|
115
|
-
it "raises UnknownObjectException if the button does not exist" do
|
116
|
-
lambda { browser.button(:name, "no_such_name").src }.should raise_error(UnknownObjectException)
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
describe "#style" do
|
121
|
-
not_compliant_on [:webdriver, :ie] do
|
122
|
-
it "returns the style attribute if the button exists" do
|
123
|
-
browser.button(:id, 'delete_user_submit').style.should == "border: 4px solid red;"
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
deviates_on [:webdriver, :ie] do
|
128
|
-
it "returns the style attribute if the button exists" do
|
129
|
-
browser.button(:id, 'delete_user_submit').style.should == "BORDER-BOTTOM: red 4px solid; BORDER-LEFT: red 4px solid; BORDER-TOP: red 4px solid; BORDER-RIGHT: red 4px solid"
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
it "returns an empty string if the element exists and the attribute doesn't exist" do
|
134
|
-
browser.button(:id, 'new_user_submit').style.should == ""
|
135
|
-
end
|
136
|
-
|
137
|
-
it "raises UnknownObjectException if the button does not exist" do
|
138
|
-
lambda { browser.button(:name, "no_such_name").style }.should raise_error(UnknownObjectException)
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
describe "#title" do
|
143
|
-
it "returns the title of the button" do
|
144
|
-
browser.button(:index, 0).title.should == 'Submit the form'
|
145
|
-
end
|
146
|
-
|
147
|
-
it "returns an empty string for button without title" do
|
148
|
-
browser.button(:index, 1).title.should == ''
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
describe "#type" do
|
153
|
-
it "returns the type if button exists" do
|
154
|
-
browser.button(:index, 0).type.should == 'submit'
|
155
|
-
browser.button(:index, 1).type.should == 'reset'
|
156
|
-
browser.button(:index, 2).type.should == 'button'
|
157
|
-
end
|
158
|
-
|
159
|
-
it "raises UnknownObjectException if button does not exist" do
|
160
|
-
lambda { browser.button(:name, "no_such_name").type }.should raise_error(UnknownObjectException)
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
describe "#value" do
|
165
|
-
it "returns the value if button exists" do
|
166
|
-
browser.button(:index, 0).value.should == 'Submit'
|
167
|
-
browser.button(:index, 1).value.should == 'Reset'
|
168
|
-
browser.button(:index, 2).value.should == 'Button'
|
169
|
-
end
|
170
|
-
|
171
|
-
it "raises UnknownObjectException if button does not exist" do
|
172
|
-
lambda { browser.button(:name, "no_such_name").value }.should raise_error(UnknownObjectException)
|
173
|
-
end
|
174
|
-
end
|
175
|
-
|
176
|
-
describe "#text" do
|
177
|
-
it "returns the text of the button" do
|
178
|
-
browser.button(:index, 0).text.should == 'Submit'
|
179
|
-
browser.button(:index, 1).text.should == 'Reset'
|
180
|
-
browser.button(:index, 2).text.should == 'Button'
|
181
|
-
browser.button(:index, 3).text.should == "Button 2"
|
182
|
-
end
|
183
|
-
|
184
|
-
it "raises UnknownObjectException if the element does not exist" do
|
185
|
-
lambda { browser.button(:id, "no_such_id").text }.should raise_error(UnknownObjectException)
|
186
|
-
end
|
187
|
-
end
|
188
|
-
|
189
|
-
describe "#respond_to?" do
|
190
|
-
it "returns true for all attribute methods" do
|
191
|
-
browser.button(:index, 0).should respond_to(:class_name)
|
192
|
-
browser.button(:index, 0).should respond_to(:id)
|
193
|
-
browser.button(:index, 0).should respond_to(:name)
|
194
|
-
browser.button(:index, 0).should respond_to(:src)
|
195
|
-
browser.button(:index, 0).should respond_to(:style)
|
196
|
-
browser.button(:index, 0).should respond_to(:title)
|
197
|
-
browser.button(:index, 0).should respond_to(:type)
|
198
|
-
browser.button(:index, 0).should respond_to(:value)
|
199
|
-
end
|
200
|
-
end
|
201
|
-
|
202
|
-
# Access methods
|
203
|
-
describe "#enabled?" do
|
204
|
-
it "returns true if the button is enabled" do
|
205
|
-
browser.button(:name, 'new_user_submit').should be_enabled
|
206
|
-
end
|
207
|
-
|
208
|
-
it "returns false if the button is disabled" do
|
209
|
-
browser.button(:name, 'new_user_submit_disabled').should_not be_enabled
|
210
|
-
end
|
211
|
-
|
212
|
-
it "raises UnknownObjectException if the button doesn't exist" do
|
213
|
-
lambda { browser.button(:name, "no_such_name").enabled? }.should raise_error(UnknownObjectException)
|
214
|
-
end
|
215
|
-
end
|
216
|
-
|
217
|
-
describe "#disabled?" do
|
218
|
-
it "returns false when button is enabled" do
|
219
|
-
browser.button(:name, 'new_user_submit').should_not be_disabled
|
220
|
-
end
|
221
|
-
|
222
|
-
it "returns true when button is disabled" do
|
223
|
-
browser.button(:name, 'new_user_submit_disabled').should be_disabled
|
224
|
-
end
|
225
|
-
|
226
|
-
it "raises UnknownObjectException if button does not exist" do
|
227
|
-
lambda { browser.button(:name, "no_such_name").disabled? }.should raise_error(UnknownObjectException)
|
228
|
-
end
|
229
|
-
end
|
230
|
-
|
231
|
-
# Manipulation methods
|
232
|
-
describe "#click" do
|
233
|
-
it "clicks the button if it exists" do
|
234
|
-
browser.goto(WatirSpec.host + "/forms_with_input_elements.html")
|
235
|
-
browser.button(:id, 'new_user_submit').click
|
236
|
-
browser.text.should include("You posted the following content:")
|
237
|
-
end
|
238
|
-
|
239
|
-
it "fires events" do
|
240
|
-
browser.button(:id, 'new_user_button').click
|
241
|
-
browser.button(:id, 'new_user_button').value.should == 'new_value_set_by_onclick_event'
|
242
|
-
end
|
243
|
-
|
244
|
-
it "raises UnknownObjectException when clicking a button that doesn't exist" do
|
245
|
-
lambda { browser.button(:value, "no_such_value").click }.should raise_error(UnknownObjectException)
|
246
|
-
lambda { browser.button(:id, "no_such_id").click }.should raise_error(UnknownObjectException)
|
247
|
-
end
|
248
|
-
|
249
|
-
it "raises ObjectDisabledException when clicking a disabled button" do
|
250
|
-
lambda { browser.button(:value, "Disabled").click }.should raise_error(ObjectDisabledException)
|
251
|
-
end
|
252
|
-
end
|
253
|
-
|
254
|
-
|
255
|
-
end
|