rwebunit 0.2.0 → 0.7.2
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 +110 -35
- data/Rakefile +6 -5
- data/lib/rwebunit/assert.rb +249 -0
- data/lib/rwebunit/driver.rb +296 -0
- data/lib/rwebunit/rspec_helper.rb +108 -0
- data/lib/rwebunit/test_context.rb +15 -10
- data/lib/rwebunit/test_utils.rb +81 -72
- data/lib/rwebunit/web_page.rb +58 -66
- data/lib/rwebunit/web_testcase.rb +20 -201
- data/lib/rwebunit/web_tester.rb +365 -399
- data/lib/rwebunit.rb +5 -0
- data/test/test_test_utils.rb +76 -73
- metadata +45 -43
data/CHANGELOG
CHANGED
@@ -1,35 +1,110 @@
|
|
1
|
-
CHANGELOG
|
2
|
-
=========
|
3
|
-
|
4
|
-
== 0.2
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
1
|
+
CHANGELOG
|
2
|
+
=========
|
3
|
+
|
4
|
+
== 0.7.2 (2007-12-31)
|
5
|
+
- Change dependency from Watir => Watir or FireWatir
|
6
|
+
Now can run on Mac or Linux
|
7
|
+
|
8
|
+
== 0.7.1 (2007-12-24)
|
9
|
+
- Fixes error when firefox is not available
|
10
|
+
|
11
|
+
== 0.7 (2007-12-18)
|
12
|
+
- support Firefox using FireWatir
|
13
|
+
|
14
|
+
== 0.6.9
|
15
|
+
- add shall_not_allow
|
16
|
+
- more watir wrapper methods
|
17
|
+
|
18
|
+
== 0.6.4 (2007-11-30)
|
19
|
+
- updated rwebunit 0.6.4
|
20
|
+
- support javascript window
|
21
|
+
- support watir td, tr...
|
22
|
+
|
23
|
+
== 0.6.0 (2007-11-18)
|
24
|
+
- support watir convenient methods
|
25
|
+
|
26
|
+
== 0.5.4 (2007-11-12)
|
27
|
+
- fixed element_by_id
|
28
|
+
|
29
|
+
== 0.5.3 (2007-11-07)
|
30
|
+
- fixed ajax_wait_element with web_tester changes
|
31
|
+
- added wait_for_element
|
32
|
+
|
33
|
+
== 0.5.2 (2007-09-27)
|
34
|
+
- added element_text
|
35
|
+
|
36
|
+
== 0.5.1 (2007-09-21)
|
37
|
+
- add wrap of Watir methods, such as buttons, button(...)
|
38
|
+
- expose Watir low level methods to test/spec through Driver.rb
|
39
|
+
- removed old way using array and comparision to access individual control
|
40
|
+
- renamed html_title to page_title
|
41
|
+
- add method contains_text
|
42
|
+
- make faster checkbox operations
|
43
|
+
- make faster radio operations
|
44
|
+
- added radio opration in driver.rb
|
45
|
+
- renamed ajax_wait_for_element
|
46
|
+
- added some comments
|
47
|
+
|
48
|
+
== 0.5.0
|
49
|
+
- Support Watir 1.5.2
|
50
|
+
|
51
|
+
== 0.4.5
|
52
|
+
- support checkboxes with same name
|
53
|
+
|
54
|
+
== 0.4.2
|
55
|
+
|
56
|
+
New Features
|
57
|
+
- Drop support for java syntax methods
|
58
|
+
- remove assert helper methods in web_tester
|
59
|
+
- improve support for RSpecs
|
60
|
+
|
61
|
+
== 0.4.0 (2007-05-29)
|
62
|
+
|
63
|
+
New features
|
64
|
+
- Support RSpec
|
65
|
+
|
66
|
+
== 0.3.1 (2007-04-18)
|
67
|
+
|
68
|
+
Bug fix reelase
|
69
|
+
|
70
|
+
== 0.3.0 (2007-02-16)
|
71
|
+
|
72
|
+
New features
|
73
|
+
- Deprecated Java like method name, use ruby naming convention instead, beginAt => begin_at
|
74
|
+
- More ajax related calls: ajax_wait_for_element_show, ajax_wait_for_element_hide, assert_position_in_list
|
75
|
+
|
76
|
+
== 0.2.0 (2006-11-28)
|
77
|
+
|
78
|
+
New features:
|
79
|
+
- wait_ajax_udpate(elem_id, seconds) - use indicator image id to determine whether the ajax request is completed or not
|
80
|
+
- browser_opened?
|
81
|
+
|
82
|
+
A number of general fixes and code improvements.
|
83
|
+
|
84
|
+
== 0.1.1
|
85
|
+
|
86
|
+
New jWebUnit API methods implemented:
|
87
|
+
assertOptionEquals(selectName, optionLabel)
|
88
|
+
assertOptionValueEquals(selectName, optionValue)
|
89
|
+
assertCheckboxNotSelected(checkBoxName)
|
90
|
+
assertCheckboxSelected(checkBoxName)
|
91
|
+
assertLinkPresentWithExactText(linkText)
|
92
|
+
assertLinkNotPresentWithExactText(linkText)
|
93
|
+
assertRadioOptionNotPresent(radioGroup, radioOption)
|
94
|
+
assertRadioOptionPresent(radioGroup, radioOption)
|
95
|
+
assertRadioOptionSelected(radioGroup, radioOption)
|
96
|
+
assertRadioOptionNotSelected(radioGroup, radioOption)
|
97
|
+
assertTextInTable(tableId, text)
|
98
|
+
assertTextNotInTable(tableId, text)
|
99
|
+
|
100
|
+
API methods modified:
|
101
|
+
assertLinkPresentWithText(linkText):
|
102
|
+
assertLinkNotPresentWithText(linkText):
|
103
|
+
|
104
|
+
New rWebUnit API :
|
105
|
+
clickRadioOption(radioGroup, radioOption): this method is protected in jWebUnit
|
106
|
+
|
107
|
+
== 0.1.0
|
108
|
+
|
109
|
+
* Initial release.
|
110
|
+
* Most common web actions and assertions implemented.
|
data/Rakefile
CHANGED
@@ -9,7 +9,7 @@ $:.unshift(File.dirname(__FILE__) + "/lib")
|
|
9
9
|
require 'rwebunit'
|
10
10
|
|
11
11
|
desc "Default task"
|
12
|
-
task :default => [ :clean, :test , :gem]
|
12
|
+
task :default => [ :clean, :test, :doc, :gem]
|
13
13
|
|
14
14
|
desc "Clean generated files"
|
15
15
|
task :clean do
|
@@ -36,13 +36,13 @@ Rake::RDocTask.new { |rdoc|
|
|
36
36
|
spec = Gem::Specification.new do |s|
|
37
37
|
s.platform= Gem::Platform::RUBY
|
38
38
|
s.name = "rwebunit"
|
39
|
-
s.version = "0.2
|
40
|
-
s.summary = "An wrap of WATIR for functional testing of web applications"
|
39
|
+
s.version = "0.7.2"
|
40
|
+
s.summary = "An wrap of WATIR/FireWatir for functional testing of web applications"
|
41
41
|
# s.description = ""
|
42
42
|
|
43
43
|
s.author = "Zhimin Zhan"
|
44
44
|
s.email = "zhimin@zhimin.com"
|
45
|
-
s.homepage= "http://
|
45
|
+
s.homepage= "http://code.google.com/p/rwebunit/"
|
46
46
|
# s.rubyforge_project = ""
|
47
47
|
|
48
48
|
s.has_rdoc = true
|
@@ -57,7 +57,8 @@ spec = Gem::Specification.new do |s|
|
|
57
57
|
s.files = s.files + Dir.glob( "sample/**/*" ).delete_if { |item| item.include?( "\.svn" ) }
|
58
58
|
s.files = s.files + Dir.glob( "docs/**/*" ).delete_if { |item| item.include?( "\.svn" ) }
|
59
59
|
|
60
|
-
s.add_dependency("watir", ">= 1.
|
60
|
+
# s.add_dependency("watir", ">= 1.5.3")
|
61
|
+
# s.add_dependency("firewatir", ">= 1.1")
|
61
62
|
end
|
62
63
|
|
63
64
|
Rake::GemPackageTask.new(spec) do |pkg|
|
@@ -0,0 +1,249 @@
|
|
1
|
+
require 'runit/assert'
|
2
|
+
|
3
|
+
module RWebUnit
|
4
|
+
module Assert
|
5
|
+
|
6
|
+
include RUNIT::Assert
|
7
|
+
|
8
|
+
#TODO for drag-n-drop, check the postion in list
|
9
|
+
# def assert_position_in_list(list_element_id)
|
10
|
+
# raise "not implemented"
|
11
|
+
# end
|
12
|
+
|
13
|
+
##
|
14
|
+
# text
|
15
|
+
def assert_text_present(text)
|
16
|
+
assert((@web_tester.page_source.include? text), 'expected text: ' + text + ' not found')
|
17
|
+
end
|
18
|
+
|
19
|
+
def assert_text_not_present(text)
|
20
|
+
assert(!(@web_tester.page_source.include? text), 'expected text: ' + text + ' found')
|
21
|
+
end
|
22
|
+
|
23
|
+
def assert_text_in_table(tableId, text)
|
24
|
+
elem = element_by_id(tableId)
|
25
|
+
assert_not_nil(elem, "tableId #{tableId} not exists")
|
26
|
+
assert_equal(elem.tagName.upcase, "TABLE")
|
27
|
+
puts elem.innerHTML if $DEBUG
|
28
|
+
assert(elem.innerHTML.include?(text), "the text #{text} not found in table #{tableId}")
|
29
|
+
end
|
30
|
+
|
31
|
+
def assert_text_not_in_table(tableId, text)
|
32
|
+
elem = element_by_id(tableId)
|
33
|
+
assert_equal(elem.tagName.upcase, "TABLE")
|
34
|
+
assert_not_nil(elem, "tableId #{tableId} not exists")
|
35
|
+
assert(!elem.innerHTML.include?(text), "unexpected text #{text} found in table #{tableId}")
|
36
|
+
end
|
37
|
+
|
38
|
+
def assert_element_present(elementID)
|
39
|
+
assert_not_nil(element_by_id(elementID), "element with id #{elementID} not found")
|
40
|
+
end
|
41
|
+
|
42
|
+
def assert_element_not_present(elementID)
|
43
|
+
assert_nil(element_by_id(elementID), "unexpected element with id #{elementID} found")
|
44
|
+
end
|
45
|
+
|
46
|
+
def assert_text_in_element(elementID, text)
|
47
|
+
elem = element_by_id(elementID)
|
48
|
+
assert_not_nil(elem.innerText, "element #{elementID} has no text")
|
49
|
+
assert(elem.innerText.include?(text), "the text #{text} not found in element #{elementID}")
|
50
|
+
end
|
51
|
+
|
52
|
+
##
|
53
|
+
# Checkbox
|
54
|
+
def assert_checkbox_not_selected(checkBoxName)
|
55
|
+
@web_tester.checkboxes.each { |checkbox|
|
56
|
+
if (checkbox.name == checkBoxName) then
|
57
|
+
assert(!checkbox.isSet?, "Checkbox #{checkBoxName} checked unexpected")
|
58
|
+
end
|
59
|
+
}
|
60
|
+
end
|
61
|
+
|
62
|
+
def assert_checkbox_selected(checkBoxName)
|
63
|
+
@web_tester.checkboxes.each { |checkbox|
|
64
|
+
if (checkbox.name == checkBoxName) then
|
65
|
+
assert(checkbox.isSet?, "Checkbox #{checkBoxName} not checked")
|
66
|
+
end
|
67
|
+
}
|
68
|
+
end
|
69
|
+
|
70
|
+
##
|
71
|
+
# select
|
72
|
+
def assert_option_value_not_present(selectName, optionValue)
|
73
|
+
@web_tester.select_lists.each { |select|
|
74
|
+
continue unless select.name == selectName
|
75
|
+
select.o.each do |option| # items in the list
|
76
|
+
assert(!(option.value == optionValue), "unexpected select option: #{optionValue} for #{selectName} found")
|
77
|
+
end
|
78
|
+
}
|
79
|
+
end
|
80
|
+
|
81
|
+
def assert_option_not_present(selectName, optionLabel)
|
82
|
+
@web_tester.select_lists.each { |select|
|
83
|
+
next unless select.name == selectName
|
84
|
+
select.o.each do |option| # items in the list
|
85
|
+
assert(!(option.text == optionLabel), "unexpected select option: #{optionLabel} for #{selectName} found")
|
86
|
+
end
|
87
|
+
}
|
88
|
+
end
|
89
|
+
|
90
|
+
def assert_option_value_present(selectName, optionValue)
|
91
|
+
@web_tester.select_lists.each { |select|
|
92
|
+
next unless select.name == selectName
|
93
|
+
select.o.each do |option| # items in the list
|
94
|
+
return if option.value == optionValue
|
95
|
+
end
|
96
|
+
}
|
97
|
+
assert(false, "can't find the combob box with value: #{optionValue}")
|
98
|
+
end
|
99
|
+
|
100
|
+
def assert_option_present(selectName, optionLabel)
|
101
|
+
@web_tester.select_lists.each { |select|
|
102
|
+
next unless select.name == selectName
|
103
|
+
select.o.each do |option| # items in the list
|
104
|
+
return if option.text == optionLabel
|
105
|
+
end
|
106
|
+
}
|
107
|
+
assert(false, "can't find the combob box: #{selectName} with value: #{optionLabel}")
|
108
|
+
end
|
109
|
+
|
110
|
+
def assert_option_equals(selectName, optionLabel)
|
111
|
+
@web_tester.select_lists.each { |select|
|
112
|
+
next unless select.name == selectName
|
113
|
+
select.o.each do |option| # items in the list
|
114
|
+
if (option.text == optionLabel) then
|
115
|
+
assert_equal(select.value, option.value, "Select #{selectName}'s value is not equal to expected option label: '#{optionLabel}'")
|
116
|
+
end
|
117
|
+
end
|
118
|
+
}
|
119
|
+
end
|
120
|
+
|
121
|
+
def assert_option_value_equals(selectName, optionValue)
|
122
|
+
@web_tester.select_lists.each { |select|
|
123
|
+
next unless select.name == selectName
|
124
|
+
assert_equal(select.value, optionValue, "Select #{selectName}'s value is not equal to expected: '#{optionValue}'")
|
125
|
+
}
|
126
|
+
end
|
127
|
+
|
128
|
+
##
|
129
|
+
# radio
|
130
|
+
|
131
|
+
# radioGroup is the name field, radio options 'value' field
|
132
|
+
def assert_radio_option_not_present(radioGroup, radioOption)
|
133
|
+
@web_tester.radios.each { |radio|
|
134
|
+
if (radio.name == radioGroup) then
|
135
|
+
assert(!(radioOption == radio.value), "unexpected radio option: " + radioOption + " found")
|
136
|
+
end
|
137
|
+
}
|
138
|
+
end
|
139
|
+
|
140
|
+
def assert_radio_option_present(radioGroup, radioOption)
|
141
|
+
@web_tester.radios.each { |radio|
|
142
|
+
return if (radio.name == radioGroup) and (radioOption == radio.value)
|
143
|
+
}
|
144
|
+
fail("can't find the radio option : '#{radioOption}'")
|
145
|
+
end
|
146
|
+
|
147
|
+
def assert_radio_option_selected(radioGroup, radioOption)
|
148
|
+
@web_tester.radios.each { |radio|
|
149
|
+
if (radio.name == radioGroup and radioOption == radio.value) then
|
150
|
+
assert(radio.isSet?, "Radio button #{radioGroup}-[#{radioOption}] not checked")
|
151
|
+
end
|
152
|
+
}
|
153
|
+
end
|
154
|
+
|
155
|
+
def assert_radio_option_not_selected(radioGroup, radioOption)
|
156
|
+
@web_tester.radios.each { |radio|
|
157
|
+
if (radio.name == radioGroup and radioOption == radio.value) then
|
158
|
+
assert(!radio.isSet?, "Radio button #{radioGroup}-[#{radioOption}] checked unexpected")
|
159
|
+
end
|
160
|
+
}
|
161
|
+
end
|
162
|
+
|
163
|
+
##
|
164
|
+
# Button
|
165
|
+
def assert_button_not_present(buttonId)
|
166
|
+
@web_tester.buttons.each { |button|
|
167
|
+
assert(button.id != buttonId, "unexpected button id: #{buttonId} found")
|
168
|
+
}
|
169
|
+
end
|
170
|
+
|
171
|
+
def assert_button_not_present_with_text(text)
|
172
|
+
@web_tester.buttons.each { |button|
|
173
|
+
assert(button.value != text, "unexpected button id: #{text} found")
|
174
|
+
}
|
175
|
+
end
|
176
|
+
|
177
|
+
def assert_button_present(buttonID)
|
178
|
+
@web_tester.buttons.each { |button|
|
179
|
+
return if buttonID == button.id
|
180
|
+
}
|
181
|
+
assert(false, "can't find the button with id: #{buttonID}")
|
182
|
+
end
|
183
|
+
|
184
|
+
def assert_button_present_with_text(buttonText)
|
185
|
+
@web_tester.buttons.each { |button|
|
186
|
+
return if buttonText == button.value
|
187
|
+
}
|
188
|
+
assert(false, "can't find the button with text: #{buttonText}")
|
189
|
+
end
|
190
|
+
|
191
|
+
##
|
192
|
+
# Link
|
193
|
+
def assert_link_present_with_exact(linkText)
|
194
|
+
@web_tester.links.each { |link|
|
195
|
+
return if linkText == link.text
|
196
|
+
}
|
197
|
+
fail( "can't find the link with text: #{linkText}")
|
198
|
+
end
|
199
|
+
|
200
|
+
def assert_link_not_present_with_exact(linkText)
|
201
|
+
@web_tester.links.each { |link|
|
202
|
+
assert(linkText != link.text, "unexpected link (exact): #{linkText} found")
|
203
|
+
}
|
204
|
+
end
|
205
|
+
|
206
|
+
def assert_link_present_with_text(linkText)
|
207
|
+
@web_tester.links.each { |link|
|
208
|
+
return if link.text.include?(linkText)
|
209
|
+
}
|
210
|
+
fail( "can't find the link containing text: #{linkText}")
|
211
|
+
end
|
212
|
+
|
213
|
+
def assert_link_not_present_with_text(linkText)
|
214
|
+
@web_tester.links.each { |link|
|
215
|
+
assert(!link.Text.include?(linkText), "unexpected link containing: #{linkText} found")
|
216
|
+
}
|
217
|
+
end
|
218
|
+
|
219
|
+
def assert_text_present_in_text_field(textfieldName, text, msg = nil)
|
220
|
+
@web_tester.textfields.each { |textfield|
|
221
|
+
if (textfield.name == textfieldName) then
|
222
|
+
assert(text_field.value.include?(text), "text: #{text} not in text field: " + textfieldName)
|
223
|
+
end
|
224
|
+
}
|
225
|
+
end
|
226
|
+
|
227
|
+
# assertions
|
228
|
+
def assert_title_equals(title)
|
229
|
+
assert_equals(title, @web_tester.page_title)
|
230
|
+
end
|
231
|
+
|
232
|
+
def assert_equals(expected, actual, msg=nil)
|
233
|
+
assert(expected == actual, (msg.nil?) ? "Expected: #{expected} diff from actual: #{actual}" : msg)
|
234
|
+
end
|
235
|
+
|
236
|
+
def assert_nil(actual, msg="")
|
237
|
+
assert(actual.nil?, msg)
|
238
|
+
end
|
239
|
+
|
240
|
+
def assert_not_nil(actual, msg="")
|
241
|
+
assert(!actual.nil?, msg)
|
242
|
+
end
|
243
|
+
|
244
|
+
def fail(message)
|
245
|
+
assert(false, message)
|
246
|
+
end
|
247
|
+
|
248
|
+
end
|
249
|
+
end
|