rwebunit 0.1 → 0.1.1
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/CHANGELOG +24 -0
- data/Rakefile +2 -2
- data/docs/html/index.html +18 -18
- data/lib/rwebunit/web_testcase.rb +58 -0
- data/lib/rwebunit/web_tester.rb +127 -11
- data/sample/README.txt +21 -0
- data/sample/kangxi_home_webtest.rb +37 -0
- data/sample/kangxi_httpcaller_webtest.rb +33 -0
- data/sample/{kongming_pages.rb → kangxi_pages.rb} +13 -14
- data/sample/kangxi_xml_formatter_webtest.rb +44 -0
- data/sample/rwebunit_home_testcase.rb +22 -0
- data/sample/sample_rwebunit_test.rb +1 -0
- data/sample/sample_watir_test.rb +1 -0
- metadata +9 -5
- data/sample/kongming_webtest.rb +0 -79
data/CHANGELOG
CHANGED
|
@@ -1,4 +1,28 @@
|
|
|
1
1
|
CHANGELOG
|
|
2
|
+
=========
|
|
3
|
+
|
|
4
|
+
== 0.1.1
|
|
5
|
+
|
|
6
|
+
New jWebUnit API methods implemented:
|
|
7
|
+
assertOptionEquals(selectName, optionLabel)
|
|
8
|
+
assertOptionValueEquals(selectName, optionValue)
|
|
9
|
+
assertCheckboxNotSelected(checkBoxName)
|
|
10
|
+
assertCheckboxSelected(checkBoxName)
|
|
11
|
+
assertLinkPresentWithExactText(linkText)
|
|
12
|
+
assertLinkNotPresentWithExactText(linkText)
|
|
13
|
+
assertRadioOptionNotPresent(radioGroup, radioOption)
|
|
14
|
+
assertRadioOptionPresent(radioGroup, radioOption)
|
|
15
|
+
assertRadioOptionSelected(radioGroup, radioOption)
|
|
16
|
+
assertRadioOptionNotSelected(radioGroup, radioOption)
|
|
17
|
+
assertTextInTable(tableId, text)
|
|
18
|
+
assertTextNotInTable(tableId, text)
|
|
19
|
+
|
|
20
|
+
API methods modified:
|
|
21
|
+
assertLinkPresentWithText(linkText):
|
|
22
|
+
assertLinkNotPresentWithText(linkText):
|
|
23
|
+
|
|
24
|
+
New rWebUnit API :
|
|
25
|
+
clickRadioOption(radioGroup, radioOption): this method is protected in jWebUnit
|
|
2
26
|
|
|
3
27
|
== 0.1.0
|
|
4
28
|
|
data/Rakefile
CHANGED
|
@@ -37,13 +37,13 @@ Rake::RDocTask.new { |rdoc|
|
|
|
37
37
|
spec = Gem::Specification.new do |s|
|
|
38
38
|
s.platform= Gem::Platform::RUBY
|
|
39
39
|
s.name = "rwebunit"
|
|
40
|
-
s.version = "0.1"
|
|
40
|
+
s.version = "0.1.1"
|
|
41
41
|
s.summary = "An wrap of WATIR for functional testing of web applications"
|
|
42
42
|
# s.description = ""
|
|
43
43
|
|
|
44
44
|
s.author = "Zhimin Zhan"
|
|
45
45
|
s.email = "zhimin@zhimin.com"
|
|
46
|
-
s.homepage= "http://www.zhimin.com/
|
|
46
|
+
s.homepage= "http://www.zhimin.com/software/rwebunit/"
|
|
47
47
|
# s.rubyforge_project = ""
|
|
48
48
|
|
|
49
49
|
s.has_rdoc = true
|
data/docs/html/index.html
CHANGED
|
@@ -22,11 +22,11 @@ class WatirSearchExample < Test::Unit::TestCase
|
|
|
22
22
|
def test_search
|
|
23
23
|
ie= Watir::IE.new
|
|
24
24
|
ie.goto("http://www.google.com")
|
|
25
|
-
ie.text_field( :name, "
|
|
26
|
-
ie.button( :name, "
|
|
27
|
-
ie.link( :text, "
|
|
28
|
-
assert_equal("
|
|
29
|
-
assert( ie.contains_text("
|
|
25
|
+
ie.text_field( :name, "q"). set("httpunit")
|
|
26
|
+
ie.button( :name, "btnG"). click
|
|
27
|
+
ie.link( :text, "HttpUnit Home"). click
|
|
28
|
+
assert_equal("HttpUnit Home", ie.document.title)
|
|
29
|
+
assert( ie.contains_text("User' s Manual"))
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
end
|
|
@@ -44,11 +44,11 @@ class RWebUnitSearchExample < RWebUnit::WebTestCase
|
|
|
44
44
|
def test_search()
|
|
45
45
|
getTestContext().base_url="http://www.google.com"
|
|
46
46
|
beginAt("/")
|
|
47
|
-
setFormElement("
|
|
48
|
-
clickButtonWithValue("
|
|
49
|
-
clickLinkWithText("
|
|
50
|
-
assertTitleEquals("
|
|
51
|
-
assertLinkPresentWithText("
|
|
47
|
+
setFormElement("q", "httpunit")
|
|
48
|
+
clickButtonWithValue("Google Search")
|
|
49
|
+
clickLinkWithText("HttpUnit Home")
|
|
50
|
+
assertTitleEquals("HttpUnit Home")
|
|
51
|
+
assertLinkPresentWithText("User' s Manual")
|
|
52
52
|
end
|
|
53
53
|
|
|
54
54
|
end
|
|
@@ -100,21 +100,21 @@ require 'rwebunit'
|
|
|
100
100
|
|
|
101
101
|
class RWebUnitSearchExample < RWebUnit::WebTestCase
|
|
102
102
|
|
|
103
|
-
def initialize(
|
|
104
|
-
super(
|
|
103
|
+
def initialize(name)
|
|
104
|
+
super(name)
|
|
105
105
|
end
|
|
106
106
|
|
|
107
107
|
def setup
|
|
108
|
-
getTestContext().
|
|
108
|
+
getTestContext().setBaseUrl("http:// www.google.com")
|
|
109
109
|
end
|
|
110
110
|
|
|
111
111
|
def test_search
|
|
112
112
|
beginAt("/")
|
|
113
|
-
setFormElement("
|
|
114
|
-
submit("
|
|
115
|
-
clickLinkWithText("
|
|
116
|
-
assertTitleEquals("
|
|
117
|
-
assertLinkPresentWithText("
|
|
113
|
+
setFormElement("q", "httpunit")
|
|
114
|
+
submit("btnG")
|
|
115
|
+
clickLinkWithText("HttpUnit Home")
|
|
116
|
+
assertTitleEquals("HttpUnit Home")
|
|
117
|
+
assertLinkPresentWithText("User' s Manual")
|
|
118
118
|
end
|
|
119
119
|
end
|
|
120
120
|
</pre>
|
|
@@ -63,6 +63,14 @@ class WebTestCase < Test::Unit::TestCase
|
|
|
63
63
|
@web_tester.assertTextNotPresent(text)
|
|
64
64
|
end
|
|
65
65
|
|
|
66
|
+
def assertTextInTable(tableId, text)
|
|
67
|
+
@web_tester.assertTextInTable(tableId, text)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def assertTextNotInTable(tableId, text)
|
|
71
|
+
@web_tester.assertTextNotInTable(tableId, text)
|
|
72
|
+
end
|
|
73
|
+
|
|
66
74
|
# textfields
|
|
67
75
|
def setFormElement(elementName, elementValue)
|
|
68
76
|
@web_tester.setFormElement(elementName, elementValue)
|
|
@@ -134,6 +142,31 @@ class WebTestCase < Test::Unit::TestCase
|
|
|
134
142
|
@web_tester.uncheckCheckbox(checkBoxName)
|
|
135
143
|
end
|
|
136
144
|
|
|
145
|
+
def assertCheckboxNotSelected(checkBoxName)
|
|
146
|
+
@web_tester.assertCheckboxNotSelected(checkBoxName)
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
def assertCheckboxSelected(checkBoxName)
|
|
150
|
+
@web_tester.assertCheckboxSelected(checkBoxName)
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
# radio button
|
|
154
|
+
def assertRadioOptionNotPresent(radioGroup, radioOption)
|
|
155
|
+
@web_tester.assertRadioOptionNotPresent(radioGroup, radioOption)
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
def assertRadioOptionPresent(radioGroup, radioOption)
|
|
159
|
+
@web_tester.assertRadioOptionPresent(radioGroup, radioOption)
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
def assertRadioOptionSelected(radioGroup, radioOption)
|
|
163
|
+
@web_tester.assertRadioOptionSelected(radioGroup, radioOption)
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
def assertRadioOptionNotSelected(radioGroup, radioOption)
|
|
167
|
+
@web_tester.assertRadioOptionNotSelected(radioGroup, radioOption)
|
|
168
|
+
end
|
|
169
|
+
|
|
137
170
|
# combo box
|
|
138
171
|
def selectOption(selectName, option)
|
|
139
172
|
@web_tester.selectOption(selectName, option)
|
|
@@ -148,6 +181,31 @@ class WebTestCase < Test::Unit::TestCase
|
|
|
148
181
|
@web_tester.assertElementNotPresent(elementID)
|
|
149
182
|
end
|
|
150
183
|
|
|
184
|
+
# Wait for specific seconds for an Ajax update finish.
|
|
185
|
+
# Trick: In your Rails application,
|
|
186
|
+
# :loading => "Element.show('search_indicator');
|
|
187
|
+
# :complete => "Element.hide('search_indicator');
|
|
188
|
+
#
|
|
189
|
+
# <%= image_tag("indicator.gif", :id => 'search_indicator', :style => 'display:none') %>
|
|
190
|
+
#
|
|
191
|
+
# In your test case:
|
|
192
|
+
# wait_ajax_update(ie, 30, "search_indicator", "Indicator", "/images/indicator.gif")
|
|
193
|
+
# or
|
|
194
|
+
# wait_ajax_update(ie, 30, "search_indicator")
|
|
195
|
+
#
|
|
196
|
+
# Warning: this method has not been fully tested, if you are not using Rails, change your parameter accordingly.
|
|
197
|
+
#
|
|
198
|
+
def wait_ajax_update(ie, seconds, indicator_image_id, indicator_alt_text = "Indicator", indicator_image_url = "/images/indicator.gif")
|
|
199
|
+
return if seconds < 1
|
|
200
|
+
seconds.times do
|
|
201
|
+
html_content = ie.html()
|
|
202
|
+
indicator_image_html_fragment = '<IMG id=' + indicator_image_id + ' style="DISPLAY: none" alt=' + indicator_alt_text +' src="' + indicator_image_url + '">'
|
|
203
|
+
puts "checking #{indicator_image_html_fragment}" if $DEBUG
|
|
204
|
+
return if html_content.include? indicator_image_html_fragment
|
|
205
|
+
sleep 1;
|
|
206
|
+
end
|
|
207
|
+
end
|
|
208
|
+
|
|
151
209
|
# ---
|
|
152
210
|
# For deubgging
|
|
153
211
|
# ---
|
data/lib/rwebunit/web_tester.rb
CHANGED
|
@@ -70,19 +70,33 @@ class WebTester
|
|
|
70
70
|
click_link_with_text(linkText)
|
|
71
71
|
end
|
|
72
72
|
|
|
73
|
-
def
|
|
73
|
+
def assertLinkPresentWithExactText(linkText)
|
|
74
74
|
html_links.each { |link|
|
|
75
75
|
return if linkText == link.text
|
|
76
76
|
}
|
|
77
|
-
|
|
77
|
+
fail( "can't find the link with text: #{linkText}")
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def assertLinkNotPresentWithExactText(linkText)
|
|
81
|
+
html_links.each { |link|
|
|
82
|
+
assert(linkText != link.text, "unexpected link (exact): #{linkText} found")
|
|
83
|
+
}
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def assertLinkPresentWithText(linkText)
|
|
87
|
+
html_links.each { |link|
|
|
88
|
+
return if link.text.include?(linkText)
|
|
89
|
+
}
|
|
90
|
+
fail( "can't find the link containing text: #{linkText}")
|
|
78
91
|
end
|
|
79
92
|
|
|
80
93
|
def assertLinkNotPresentWithText(linkText)
|
|
81
94
|
html_links.each { |link|
|
|
82
|
-
assert(
|
|
95
|
+
assert(!link.Text.include?(linkText), "unexpected link containing: #{linkText} found")
|
|
83
96
|
}
|
|
84
97
|
end
|
|
85
98
|
|
|
99
|
+
|
|
86
100
|
##
|
|
87
101
|
# buttons
|
|
88
102
|
|
|
@@ -147,14 +161,21 @@ class WebTester
|
|
|
147
161
|
end
|
|
148
162
|
|
|
149
163
|
def assertCheckboxNotSelected(checkBoxName)
|
|
150
|
-
|
|
164
|
+
html_checkboxes.each { |checkbox|
|
|
165
|
+
if (checkbox.name == checkBoxName) then
|
|
166
|
+
assert(!checkbox.isSet?, "Checkbox #{checkBoxName} checked unexpected")
|
|
167
|
+
end
|
|
168
|
+
}
|
|
151
169
|
end
|
|
152
170
|
|
|
153
171
|
def assertCheckboxSelected(checkBoxName)
|
|
154
|
-
|
|
172
|
+
html_checkboxes.each { |checkbox|
|
|
173
|
+
if (checkbox.name == checkBoxName) then
|
|
174
|
+
assert(checkbox.isSet?, "Checkbox #{checkBoxName} not checked")
|
|
175
|
+
end
|
|
176
|
+
}
|
|
155
177
|
end
|
|
156
178
|
|
|
157
|
-
|
|
158
179
|
# combo box
|
|
159
180
|
def selectOption(selectName, option)
|
|
160
181
|
@@browser.select_from_combobox_with_name(selectName, option)
|
|
@@ -162,24 +183,28 @@ class WebTester
|
|
|
162
183
|
|
|
163
184
|
def assertOptionValueNotPresent(selectName, optionValue)
|
|
164
185
|
html_selects.each { |select|
|
|
186
|
+
continue unless select.name == selectName
|
|
165
187
|
select.o.each do |option| # items in the list
|
|
166
|
-
assert(!(
|
|
188
|
+
assert(!(option.value == optionValue), "unexpected select option: #{optionValue} for #{selectName} found")
|
|
167
189
|
end
|
|
168
190
|
}
|
|
169
191
|
end
|
|
170
192
|
|
|
171
193
|
def assertOptionNotPresent(selectName, optionLabel)
|
|
172
194
|
html_selects.each { |select|
|
|
195
|
+
next unless select.name == selectName
|
|
173
196
|
select.o.each do |option| # items in the list
|
|
174
|
-
assert(!(
|
|
197
|
+
assert(!(option.text == optionLabel), "unexpected select option: #{optionLabel} for #{selectName} found")
|
|
175
198
|
end
|
|
176
199
|
}
|
|
177
200
|
end
|
|
178
201
|
|
|
202
|
+
|
|
179
203
|
def assertOptionValuePresent(selectName, optionValue)
|
|
180
204
|
html_selects.each { |select|
|
|
205
|
+
next unless select.name == selectName
|
|
181
206
|
select.o.each do |option| # items in the list
|
|
182
|
-
return if
|
|
207
|
+
return if option.value == optionValue
|
|
183
208
|
end
|
|
184
209
|
}
|
|
185
210
|
assert(false, "can't find the combob box with value: #{optionValue}")
|
|
@@ -187,16 +212,79 @@ class WebTester
|
|
|
187
212
|
|
|
188
213
|
def assertOptionPresent(selectName, optionLabel)
|
|
189
214
|
html_selects.each { |select|
|
|
215
|
+
next unless select.name == selectName
|
|
190
216
|
select.o.each do |option| # items in the list
|
|
191
|
-
return if
|
|
217
|
+
return if option.text == optionLabel
|
|
192
218
|
end
|
|
193
219
|
}
|
|
194
220
|
assert(false, "can't find the combob box: #{selectName} with value: #{optionLabel}")
|
|
195
221
|
end
|
|
196
222
|
|
|
223
|
+
def assertOptionEquals(selectName, optionLabel)
|
|
224
|
+
html_selects.each { |select|
|
|
225
|
+
next unless select.name == selectName
|
|
226
|
+
select.o.each do |option| # items in the list
|
|
227
|
+
if (option.text == optionLabel) then
|
|
228
|
+
assert_equal(select.value, option.value, "Select #{selectName}'s value is not equal to expected option label: '#{optionLabel}'")
|
|
229
|
+
end
|
|
230
|
+
end
|
|
231
|
+
}
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
def assertOptionValueEquals(selectName, optionValue)
|
|
236
|
+
html_selects.each { |select|
|
|
237
|
+
next unless select.name == selectName
|
|
238
|
+
assert_equal(select.value, optionValue, "Select #{selectName}'s value is not equal to expected: '#{optionValue}'")
|
|
239
|
+
}
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
#radio
|
|
244
|
+
|
|
245
|
+
# radioGroup is the name field, radio options 'value' field
|
|
246
|
+
def assertRadioOptionNotPresent(radioGroup, radioOption)
|
|
247
|
+
html_radios.each { |radio|
|
|
248
|
+
if (radio.name == radioGroup) then
|
|
249
|
+
assert(!(radioOption == radio.value), "unexpected radio option: " + radioOption + " found")
|
|
250
|
+
end
|
|
251
|
+
}
|
|
252
|
+
end
|
|
253
|
+
|
|
254
|
+
def assertRadioOptionPresent(radioGroup, radioOption)
|
|
255
|
+
html_radios.each { |radio|
|
|
256
|
+
return if (radio.name == radioGroup) and (radioOption == radio.value)
|
|
257
|
+
}
|
|
258
|
+
fail("can't find the radio option : '#{radioOption}'")
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
def assertRadioOptionSelected(radioGroup, radioOption)
|
|
262
|
+
html_radios.each { |radio|
|
|
263
|
+
if (radio.name == radioGroup and radioOption == radio.value) then
|
|
264
|
+
assert(radio.isSet?, "Radio button #{radioGroup}-[#{radioOption}] not checked")
|
|
265
|
+
end
|
|
266
|
+
}
|
|
267
|
+
end
|
|
268
|
+
|
|
269
|
+
def assertRadioOptionNotSelected(radioGroup, radioOption)
|
|
270
|
+
html_radios.each { |radio|
|
|
271
|
+
if (radio.name == radioGroup and radioOption == radio.value) then
|
|
272
|
+
assert(!radio.isSet?, "Radio button #{radioGroup}-[#{radioOption}] checked unexpected")
|
|
273
|
+
end
|
|
274
|
+
}
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
# the method is protected in JWebUnit
|
|
278
|
+
def clickRadioOption(radioGroup, radioOption)
|
|
279
|
+
html_radios.each { |radio|
|
|
280
|
+
if (radio.name == radioGroup and radioOption == radio.value) then
|
|
281
|
+
radio.set
|
|
282
|
+
end
|
|
283
|
+
}
|
|
284
|
+
end
|
|
285
|
+
|
|
197
286
|
#text
|
|
198
287
|
def assertTextPresent(text)
|
|
199
|
-
puts html_body() if $DEBUG
|
|
200
288
|
assert((html_body().include? text), 'expected text: ' + text + ' not found')
|
|
201
289
|
end
|
|
202
290
|
|
|
@@ -204,6 +292,22 @@ class WebTester
|
|
|
204
292
|
assert(!(html_body().include? text), 'expected text: ' + text + ' found')
|
|
205
293
|
end
|
|
206
294
|
|
|
295
|
+
|
|
296
|
+
def assertTextInTable(tableId, text)
|
|
297
|
+
elem = @@browser.document.getElementById(tableId)
|
|
298
|
+
assert_not_nil(elem, "tableId #{tableId} not exists")
|
|
299
|
+
assert_equal(elem.tagName, "TABLE")
|
|
300
|
+
puts elem.innerHTML if $DEBUG
|
|
301
|
+
assert(elem.innerHTML.include?(text), "the text #{text} not found in table #{tableId}")
|
|
302
|
+
end
|
|
303
|
+
|
|
304
|
+
def assertTextNotInTable(tableId, text)
|
|
305
|
+
elem = @@browser.document.getElementById(tableId)
|
|
306
|
+
assert_equal(elem.name.uppercase, "TABLE")
|
|
307
|
+
assert_not_nil(elem, "tableId #{tableId} not exists")
|
|
308
|
+
assert(!elem.innerHTML.include?(text), "unexpected text #{text} found in table #{tableId}")
|
|
309
|
+
end
|
|
310
|
+
|
|
207
311
|
def assertElementPresent(elementID)
|
|
208
312
|
elem = @@browser.document.getElementById(elementID)
|
|
209
313
|
assert_not_nil(elem)
|
|
@@ -259,6 +363,14 @@ private
|
|
|
259
363
|
@@browser.select_lists
|
|
260
364
|
end
|
|
261
365
|
|
|
366
|
+
def html_checkboxes
|
|
367
|
+
@@browser.checkboxes
|
|
368
|
+
end
|
|
369
|
+
|
|
370
|
+
def html_radios
|
|
371
|
+
@@browser.radios
|
|
372
|
+
end
|
|
373
|
+
|
|
262
374
|
def assert_equals(expected, actual, msg=nil)
|
|
263
375
|
assert(expected == actual, (msg.nil?) ? "Expected: #{expected} diff from actual: #{actual}" : msg)
|
|
264
376
|
end
|
|
@@ -272,6 +384,10 @@ private
|
|
|
272
384
|
assert(!actual.nil?, msg)
|
|
273
385
|
end
|
|
274
386
|
|
|
387
|
+
def fail(message)
|
|
388
|
+
assert(false, message)
|
|
389
|
+
end
|
|
390
|
+
|
|
275
391
|
end
|
|
276
392
|
|
|
277
393
|
end
|
data/sample/README.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
|
|
2
|
+
Sample tests
|
|
3
|
+
============
|
|
4
|
+
|
|
5
|
+
1. Comparing Watir and RWebUnit:
|
|
6
|
+
sample_rwebunit_test.rb
|
|
7
|
+
sample_watir_test.rb
|
|
8
|
+
|
|
9
|
+
2. Comparing RWebUnit and JWebUnit:
|
|
10
|
+
sample_rwebunit_testcase.rb
|
|
11
|
+
|
|
12
|
+
3. A more complex single web test
|
|
13
|
+
rwebunit_home_test.rb
|
|
14
|
+
|
|
15
|
+
4. An organised set of web tets against a web application, using TestCase + TestPage design:
|
|
16
|
+
kangxi_pages.rb
|
|
17
|
+
kangxi_httpcaller_webtest.rb
|
|
18
|
+
kangxi_xml_formatter_webtest.rb
|
|
19
|
+
kangxi_home_webtest.rb
|
|
20
|
+
|
|
21
|
+
Note: Kangxi is a rails web application.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#$:.unshift File.join(File.dirname(__FILE__), "..", "lib/rwebunit")
|
|
2
|
+
|
|
3
|
+
require "rwebunit"
|
|
4
|
+
|
|
5
|
+
$:.unshift File.dirname(__FILE__)
|
|
6
|
+
require "kangxi_pages.rb"
|
|
7
|
+
|
|
8
|
+
class TestWuning < RWebUnit::WebTestCase
|
|
9
|
+
|
|
10
|
+
def initialize(name)
|
|
11
|
+
super(name)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def setup
|
|
15
|
+
super
|
|
16
|
+
getTestContext().base_url = "http://localhost:3721"
|
|
17
|
+
beginAt("/home")
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def teardown
|
|
21
|
+
super
|
|
22
|
+
closeBrowser()
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def test_homepage_exists()
|
|
26
|
+
kangxi_homepage = KangxiHomePage.new(@web_tester, "Welcome")
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def test_all_links_exist
|
|
30
|
+
kangxi_homepage = KangxiHomePage.new(@web_tester, "Welcome")
|
|
31
|
+
kangxi_homepage.assertTheListLinkPresent()
|
|
32
|
+
kangxi_homepage.assertDashboardLinkPresent
|
|
33
|
+
kangxi_homepage.assertTestCenterLinkPresent
|
|
34
|
+
kangxi_homepage.assertTestWebServiceLinkPresent
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#$:.unshift File.join(File.dirname(__FILE__), "..", "lib/rwebunit")
|
|
2
|
+
|
|
3
|
+
require "rwebunit"
|
|
4
|
+
|
|
5
|
+
$:.unshift File.dirname(__FILE__)
|
|
6
|
+
require "kangxi_pages.rb"
|
|
7
|
+
|
|
8
|
+
class TestHttpCaller < RWebUnit::WebTestCase
|
|
9
|
+
|
|
10
|
+
def initialize(name)
|
|
11
|
+
super(name)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def setup
|
|
15
|
+
super
|
|
16
|
+
getTestContext().base_url = "http://localhost:3721"
|
|
17
|
+
beginAt("/http")
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def teardown
|
|
21
|
+
super
|
|
22
|
+
closeBrowser()
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def test_can_display()
|
|
26
|
+
kangxi_httpcaller_page = KangxiHttpCallerPage.new(@web_tester)
|
|
27
|
+
@web_tester.assertOptionValuePresent("method", "POST")
|
|
28
|
+
@web_tester.assertOptionValuePresent("method", "GET")
|
|
29
|
+
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require "rwebunit"
|
|
2
2
|
|
|
3
|
-
class
|
|
3
|
+
class KangxiHomePage < RWebUnit::AbstractWebPage
|
|
4
4
|
|
|
5
5
|
def initialize(browser, title)
|
|
6
6
|
super(browser, title)
|
|
@@ -24,20 +24,15 @@ class KongmingHomePage < RWebUnit::AbstractWebPage
|
|
|
24
24
|
|
|
25
25
|
def clickXMLFormatterLink
|
|
26
26
|
@browser.clickLinkWithText("XML Formatter")
|
|
27
|
-
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def clickHttpCallerLink
|
|
31
|
-
@browser.clickLinkWithText("Http Caller")
|
|
32
|
-
KongmingXMLFormatterPage.new(@browser)
|
|
27
|
+
KangxiXMLFormatterPage.new(@browser, "Format XML")
|
|
33
28
|
end
|
|
34
29
|
|
|
35
30
|
end
|
|
36
31
|
|
|
37
|
-
class
|
|
32
|
+
class KangxiXMLFormatterPage < RWebUnit::AbstractWebPage
|
|
38
33
|
|
|
39
|
-
def initialize(browser)
|
|
40
|
-
super(browser,
|
|
34
|
+
def initialize(browser, title)
|
|
35
|
+
super(browser, title)
|
|
41
36
|
end
|
|
42
37
|
|
|
43
38
|
def clickFillExampleLink
|
|
@@ -54,10 +49,14 @@ class KongmingXMLFormatterPage < RWebUnit::AbstractWebPage
|
|
|
54
49
|
|
|
55
50
|
end
|
|
56
51
|
|
|
57
|
-
class
|
|
58
|
-
|
|
52
|
+
class KangxiHttpCallerPage < RWebUnit::AbstractWebPage
|
|
59
53
|
def initialize(browser)
|
|
60
|
-
super(browser,
|
|
54
|
+
super(browser,"Http Caller")
|
|
61
55
|
end
|
|
56
|
+
end
|
|
62
57
|
|
|
63
|
-
|
|
58
|
+
class KangxiCookbookPage < RWebUnit::AbstractWebPage
|
|
59
|
+
def initialize(browser)
|
|
60
|
+
super(browser,"code recipes")
|
|
61
|
+
end
|
|
62
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#$:.unshift File.join(File.dirname(__FILE__), "..", "lib/rwebunit")
|
|
2
|
+
|
|
3
|
+
require "rwebunit"
|
|
4
|
+
|
|
5
|
+
$:.unshift File.dirname(__FILE__)
|
|
6
|
+
require "kangxi_pages.rb"
|
|
7
|
+
|
|
8
|
+
class TestXmlFormatter < RWebUnit::WebTestCase
|
|
9
|
+
|
|
10
|
+
def initialize(name)
|
|
11
|
+
super(name)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def setup
|
|
15
|
+
super
|
|
16
|
+
getTestContext().base_url = "http://localhost:3721"
|
|
17
|
+
beginAt("/home")
|
|
18
|
+
kangxi_homepage = KangxiHomePage.new(@web_tester, "Welcome")
|
|
19
|
+
@kangxi_xmlformatter_page = kangxi_homepage.clickXMLFormatterLink
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def teardown
|
|
23
|
+
super
|
|
24
|
+
closeBrowser()
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def test_can_invoke_format
|
|
28
|
+
@kangxi_xmlformatter_page.enterXml("<name><first>James</first><last>Bond</last></name>")
|
|
29
|
+
@kangxi_xmlformatter_page.clickFormat
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def test_format_sample_xml
|
|
33
|
+
@kangxi_xmlformatter_page.clickFillExampleLink
|
|
34
|
+
@web_tester.assertElementNotPresent("formatted_xml")
|
|
35
|
+
@kangxi_xmlformatter_page.submit
|
|
36
|
+
@web_tester.assertElementPresent("formatted_xml")
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def test_can_call_utils
|
|
40
|
+
@kangxi_xmlformatter_page.enterXml("<date><now>" + getToday + "</now></date>")
|
|
41
|
+
@kangxi_xmlformatter_page.clickFormat
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# the same test used in jWebUnit home page written in rWebUnit
|
|
2
|
+
require 'rwebunit'
|
|
3
|
+
|
|
4
|
+
class TestRWebUnitHome < RWebUnit::WebTestCase
|
|
5
|
+
|
|
6
|
+
def initialize(name)
|
|
7
|
+
super(name)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def setup
|
|
11
|
+
getTestContext().setBaseUrl("http://www.zhimin.com")
|
|
12
|
+
beginAt("/")
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def test_rdoc()
|
|
16
|
+
setFormElement("q", "httpunit")
|
|
17
|
+
submit("btnG")
|
|
18
|
+
clickLinkWithText("HttpUnit Home")
|
|
19
|
+
assertTitleEquals("HttpUnit Home")
|
|
20
|
+
assertLinkPresentWithText("User's Manual")
|
|
21
|
+
end
|
|
22
|
+
end
|
data/sample/sample_watir_test.rb
CHANGED
metadata
CHANGED
|
@@ -3,13 +3,13 @@ rubygems_version: 0.8.11
|
|
|
3
3
|
specification_version: 1
|
|
4
4
|
name: rwebunit
|
|
5
5
|
version: !ruby/object:Gem::Version
|
|
6
|
-
version:
|
|
7
|
-
date: 2006-
|
|
6
|
+
version: 0.1.1
|
|
7
|
+
date: 2006-05-14 00:00:00 +10:00
|
|
8
8
|
summary: An wrap of WATIR for functional testing of web applications
|
|
9
9
|
require_paths:
|
|
10
10
|
- lib
|
|
11
11
|
email: zhimin@zhimin.com
|
|
12
|
-
homepage: http://www.zhimin.com/
|
|
12
|
+
homepage: http://www.zhimin.com/software/rwebunit/
|
|
13
13
|
rubyforge_project:
|
|
14
14
|
description:
|
|
15
15
|
autorequire: rwebunit
|
|
@@ -40,11 +40,15 @@ files:
|
|
|
40
40
|
- lib/rwebunit/web_testcase.rb
|
|
41
41
|
- lib/rwebunit/web_tester.rb
|
|
42
42
|
- test/test_test_utils.rb
|
|
43
|
-
- sample/
|
|
44
|
-
- sample/kongming_webtest.rb
|
|
43
|
+
- sample/kangxi_pages.rb
|
|
45
44
|
- sample/sample_rwebunit_test.rb
|
|
46
45
|
- sample/sample_rwebunit_testcase.rb
|
|
47
46
|
- sample/sample_watir_test.rb
|
|
47
|
+
- sample/README.txt
|
|
48
|
+
- sample/kangxi_home_webtest.rb
|
|
49
|
+
- sample/kangxi_httpcaller_webtest.rb
|
|
50
|
+
- sample/kangxi_xml_formatter_webtest.rb
|
|
51
|
+
- sample/rwebunit_home_testcase.rb
|
|
48
52
|
- docs/html
|
|
49
53
|
- docs/html/index.html
|
|
50
54
|
test_files: []
|
data/sample/kongming_webtest.rb
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
require "rwebunit"
|
|
2
|
-
|
|
3
|
-
$:.unshift File.dirname(__FILE__)
|
|
4
|
-
require "kongming_pages.rb"
|
|
5
|
-
|
|
6
|
-
class TestWuning < RWebUnit::WebTestCase
|
|
7
|
-
|
|
8
|
-
def initialize(name)
|
|
9
|
-
super(name)
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def setup
|
|
13
|
-
super
|
|
14
|
-
openBrowser("http://localhost:3721", "/home")
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def teardown
|
|
18
|
-
super
|
|
19
|
-
closeBrowser()
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def test_homepage_exists()
|
|
23
|
-
kongming_homepage = KongmingHomePage.new(@web_tester, "Welcome")
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def test_all_links_exist
|
|
27
|
-
kongming_homepage = KongmingHomePage.new(@web_tester, "Welcome")
|
|
28
|
-
kongming_homepage.assertTheListLinkPresent()
|
|
29
|
-
kongming_homepage.assertDashboardLinkPresent
|
|
30
|
-
kongming_homepage.assertTestCenterLinkPresent
|
|
31
|
-
kongming_homepage.assertTestWebServiceLinkPresent
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
# enter text in a text field, then click a button
|
|
35
|
-
def test_format_xml
|
|
36
|
-
kongming_homepage = KongmingHomePage.new(@web_tester, "Welcome")
|
|
37
|
-
kongming_xmlformatter_page = kongming_homepage.clickXMLFormatterLink
|
|
38
|
-
kongming_xmlformatter_page.enterXml("<name><first>James</first><last>Bond</last></name>")
|
|
39
|
-
kongming_xmlformatter_page.clickFormat
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
# Invoke link to populate date using javascripts (clickFillExampleLink)
|
|
43
|
-
# Calling submit
|
|
44
|
-
# Check special text before and after submit
|
|
45
|
-
def test_format_xml_sample
|
|
46
|
-
kongming_homepage = KongmingHomePage.new(@web_tester, "Welcome")
|
|
47
|
-
kongming_xmlformatter_page = kongming_homepage.clickXMLFormatterLink
|
|
48
|
-
kongming_xmlformatter_page.clickFillExampleLink
|
|
49
|
-
@web_tester.assertElementNotPresent("formatted_xml")
|
|
50
|
-
kongming_xmlformatter_page.submit
|
|
51
|
-
@web_tester.assertElementPresent("formatted_xml")
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
# web testcase can utilize useful methods defined in test_utils
|
|
55
|
-
def test_can_call_utils
|
|
56
|
-
kongming_homepage = KongmingHomePage.new(@web_tester, "Welcome")
|
|
57
|
-
kongming_xmlformatter_page = kongming_homepage.clickXMLFormatterLink
|
|
58
|
-
kongming_xmlformatter_page.enterXml("<date><now>" + getToday + "</now></date>")
|
|
59
|
-
kongming_xmlformatter_page.clickFormat
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
def test_combobox
|
|
63
|
-
kongming_homepage = KongmingHomePage.new(@web_tester, "Welcome")
|
|
64
|
-
kongming_httpcaller_page = kongming_homepage.clickHttpCallerLink
|
|
65
|
-
# html:
|
|
66
|
-
# <select name="method">
|
|
67
|
-
# <option value="POST">HTTP POST </option>
|
|
68
|
-
# <option value="GET"> HTTP GET </option>
|
|
69
|
-
# </select>
|
|
70
|
-
|
|
71
|
-
@web_tester.assertOptionPresent("method", "HTTP POST") # trimmed
|
|
72
|
-
@web_tester.assertOptionPresent("method", "HTTP GET")
|
|
73
|
-
@web_tester.assertOptionNotPresent("method", "PUT")
|
|
74
|
-
@web_tester.assertOptionValuePresent("method", "POST")
|
|
75
|
-
@web_tester.assertOptionValuePresent("method", "GET")
|
|
76
|
-
@web_tester.assertOptionValueNotPresent("method", "HEAD")
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
end
|