Module: RWebUnit::Assert
- Includes:
- RUNIT::Assert
- Included in:
- AbstractWebPage, RSpecHelper, WebTestCase
- Defined in:
- lib/rwebunit/assert.rb
Instance Method Summary collapse
-
#assert_button_not_present(buttonId) ⇒ Object
Button.
- #assert_button_not_present_with_text(text) ⇒ Object
- #assert_button_present(buttonID) ⇒ Object
- #assert_button_present_with_text(buttonText) ⇒ Object
-
#assert_checkbox_not_selected(checkBoxName) ⇒ Object
Checkbox.
- #assert_checkbox_selected(checkBoxName) ⇒ Object
- #assert_element_not_present(elementID) ⇒ Object
- #assert_element_present(elementID) ⇒ Object
- #assert_equals(expected, actual, msg = nil) ⇒ Object
- #assert_link_not_present_with_exact(linkText) ⇒ Object
- #assert_link_not_present_with_text(linkText) ⇒ Object
-
#assert_link_present_with_exact(linkText) ⇒ Object
Link.
- #assert_link_present_with_text(linkText) ⇒ Object
- #assert_nil(actual, msg = "") ⇒ Object
- #assert_not_nil(actual, msg = "") ⇒ Object
- #assert_option_equals(selectName, optionLabel) ⇒ Object
- #assert_option_not_present(selectName, optionLabel) ⇒ Object
- #assert_option_present(selectName, optionLabel) ⇒ Object
- #assert_option_value_equals(selectName, optionValue) ⇒ Object
-
#assert_option_value_not_present(selectName, optionValue) ⇒ Object
select.
- #assert_option_value_present(selectName, optionValue) ⇒ Object
-
#assert_radio_option_not_present(radioGroup, radioOption) ⇒ Object
radioGroup is the name field, radio options ‘value’ field.
- #assert_radio_option_not_selected(radioGroup, radioOption) ⇒ Object
- #assert_radio_option_present(radioGroup, radioOption) ⇒ Object
- #assert_radio_option_selected(radioGroup, radioOption) ⇒ Object
- #assert_text_in_element(elementID, text) ⇒ Object
- #assert_text_in_table(tableId, text) ⇒ Object
- #assert_text_not_in_table(tableId, text) ⇒ Object
- #assert_text_not_present(text) ⇒ Object
-
#assert_text_present(text) ⇒ Object
text.
- #assert_text_present_in_text_field(textfieldName, text, msg = nil) ⇒ Object
-
#assert_title_equals(title) ⇒ Object
assertions.
- #fail(message) ⇒ Object
Instance Method Details
#assert_button_not_present(buttonId) ⇒ Object
Button
165 166 167 168 169 |
# File 'lib/rwebunit/assert.rb', line 165 def () @web_tester..each { || assert(.id != , "unexpected button id: #{} found") } end |
#assert_button_not_present_with_text(text) ⇒ Object
171 172 173 174 175 |
# File 'lib/rwebunit/assert.rb', line 171 def (text) @web_tester..each { || assert(.value != text, "unexpected button id: #{text} found") } end |
#assert_button_present(buttonID) ⇒ Object
177 178 179 180 181 182 |
# File 'lib/rwebunit/assert.rb', line 177 def () @web_tester..each { || return if == .id } assert(false, "can't find the button with id: #{}") end |
#assert_button_present_with_text(buttonText) ⇒ Object
184 185 186 187 188 189 |
# File 'lib/rwebunit/assert.rb', line 184 def () @web_tester..each { || return if == .value } assert(false, "can't find the button with text: #{}") end |
#assert_checkbox_not_selected(checkBoxName) ⇒ Object
Checkbox
54 55 56 57 58 59 60 |
# File 'lib/rwebunit/assert.rb', line 54 def assert_checkbox_not_selected(checkBoxName) @web_tester.checkboxes.each { |checkbox| if (checkbox.name == checkBoxName) then assert(!checkbox.isSet?, "Checkbox #{checkBoxName} checked unexpected") end } end |
#assert_checkbox_selected(checkBoxName) ⇒ Object
62 63 64 65 66 67 68 |
# File 'lib/rwebunit/assert.rb', line 62 def assert_checkbox_selected(checkBoxName) @web_tester.checkboxes.each { |checkbox| if (checkbox.name == checkBoxName) then assert(checkbox.isSet?, "Checkbox #{checkBoxName} not checked") end } end |
#assert_element_not_present(elementID) ⇒ Object
42 43 44 |
# File 'lib/rwebunit/assert.rb', line 42 def assert_element_not_present(elementID) assert_nil(element_by_id(elementID), "unexpected element with id #{elementID} found") end |
#assert_element_present(elementID) ⇒ Object
38 39 40 |
# File 'lib/rwebunit/assert.rb', line 38 def assert_element_present(elementID) assert_not_nil(element_by_id(elementID), "element with id #{elementID} not found") end |
#assert_equals(expected, actual, msg = nil) ⇒ Object
232 233 234 |
# File 'lib/rwebunit/assert.rb', line 232 def assert_equals(expected, actual, msg=nil) assert(expected == actual, (msg.nil?) ? "Expected: #{expected} diff from actual: #{actual}" : msg) end |
#assert_link_not_present_with_exact(linkText) ⇒ Object
200 201 202 203 204 |
# File 'lib/rwebunit/assert.rb', line 200 def assert_link_not_present_with_exact(linkText) @web_tester.links.each { |link| assert(linkText != link.text, "unexpected link (exact): #{linkText} found") } end |
#assert_link_not_present_with_text(linkText) ⇒ Object
213 214 215 216 217 |
# File 'lib/rwebunit/assert.rb', line 213 def assert_link_not_present_with_text(linkText) @web_tester.links.each { |link| assert(!link.text.include?(linkText), "unexpected link containing: #{linkText} found") } end |
#assert_link_present_with_exact(linkText) ⇒ Object
Link
193 194 195 196 197 198 |
# File 'lib/rwebunit/assert.rb', line 193 def assert_link_present_with_exact(linkText) @web_tester.links.each { |link| return if linkText == link.text } fail( "can't find the link with text: #{linkText}") end |
#assert_link_present_with_text(linkText) ⇒ Object
206 207 208 209 210 211 |
# File 'lib/rwebunit/assert.rb', line 206 def assert_link_present_with_text(linkText) @web_tester.links.each { |link| return if link.text.include?(linkText) } fail( "can't find the link containing text: #{linkText}") end |
#assert_nil(actual, msg = "") ⇒ Object
236 237 238 |
# File 'lib/rwebunit/assert.rb', line 236 def assert_nil(actual, msg="") assert(actual.nil?, msg) end |
#assert_not_nil(actual, msg = "") ⇒ Object
240 241 242 |
# File 'lib/rwebunit/assert.rb', line 240 def assert_not_nil(actual, msg="") assert(!actual.nil?, msg) end |
#assert_option_equals(selectName, optionLabel) ⇒ Object
110 111 112 113 114 115 116 117 118 119 |
# File 'lib/rwebunit/assert.rb', line 110 def assert_option_equals(selectName, optionLabel) @web_tester.select_lists.each { |select| next unless select.name == selectName select.o.each do |option| # items in the list if (option.text == optionLabel) then assert_equal(select.value, option.value, "Select #{selectName}'s value is not equal to expected option label: '#{optionLabel}'") end end } end |
#assert_option_not_present(selectName, optionLabel) ⇒ Object
81 82 83 84 85 86 87 88 |
# File 'lib/rwebunit/assert.rb', line 81 def assert_option_not_present(selectName, optionLabel) @web_tester.select_lists.each { |select| next unless select.name == selectName select.o.each do |option| # items in the list assert(!(option.text == optionLabel), "unexpected select option: #{optionLabel} for #{selectName} found") end } end |
#assert_option_present(selectName, optionLabel) ⇒ Object
100 101 102 103 104 105 106 107 108 |
# File 'lib/rwebunit/assert.rb', line 100 def assert_option_present(selectName, optionLabel) @web_tester.select_lists.each { |select| next unless select.name == selectName select.o.each do |option| # items in the list return if option.text == optionLabel end } assert(false, "can't find the combob box: #{selectName} with value: #{optionLabel}") end |
#assert_option_value_equals(selectName, optionValue) ⇒ Object
121 122 123 124 125 126 |
# File 'lib/rwebunit/assert.rb', line 121 def assert_option_value_equals(selectName, optionValue) @web_tester.select_lists.each { |select| next unless select.name == selectName assert_equal(select.value, optionValue, "Select #{selectName}'s value is not equal to expected: '#{optionValue}'") } end |
#assert_option_value_not_present(selectName, optionValue) ⇒ Object
select
72 73 74 75 76 77 78 79 |
# File 'lib/rwebunit/assert.rb', line 72 def assert_option_value_not_present(selectName, optionValue) @web_tester.select_lists.each { |select| continue unless select.name == selectName select.o.each do |option| # items in the list assert(!(option.value == optionValue), "unexpected select option: #{optionValue} for #{selectName} found") end } end |
#assert_option_value_present(selectName, optionValue) ⇒ Object
90 91 92 93 94 95 96 97 98 |
# File 'lib/rwebunit/assert.rb', line 90 def assert_option_value_present(selectName, optionValue) @web_tester.select_lists.each { |select| next unless select.name == selectName select.o.each do |option| # items in the list return if option.value == optionValue end } assert(false, "can't find the combob box with value: #{optionValue}") end |
#assert_radio_option_not_present(radioGroup, radioOption) ⇒ Object
radioGroup is the name field, radio options ‘value’ field
132 133 134 135 136 137 138 |
# File 'lib/rwebunit/assert.rb', line 132 def assert_radio_option_not_present(radioGroup, radioOption) @web_tester.radios.each { |radio| if (radio.name == radioGroup) then assert(!(radioOption == radio.value), "unexpected radio option: " + radioOption + " found") end } end |
#assert_radio_option_not_selected(radioGroup, radioOption) ⇒ Object
155 156 157 158 159 160 161 |
# File 'lib/rwebunit/assert.rb', line 155 def assert_radio_option_not_selected(radioGroup, radioOption) @web_tester.radios.each { |radio| if (radio.name == radioGroup and radioOption == radio.value) then assert(!radio.isSet?, "Radio button #{radioGroup}-[#{radioOption}] checked unexpected") end } end |
#assert_radio_option_present(radioGroup, radioOption) ⇒ Object
140 141 142 143 144 145 |
# File 'lib/rwebunit/assert.rb', line 140 def assert_radio_option_present(radioGroup, radioOption) @web_tester.radios.each { |radio| return if (radio.name == radioGroup) and (radioOption == radio.value) } fail("can't find the radio option : '#{radioOption}'") end |
#assert_radio_option_selected(radioGroup, radioOption) ⇒ Object
147 148 149 150 151 152 153 |
# File 'lib/rwebunit/assert.rb', line 147 def assert_radio_option_selected(radioGroup, radioOption) @web_tester.radios.each { |radio| if (radio.name == radioGroup and radioOption == radio.value) then assert(radio.isSet?, "Radio button #{radioGroup}-[#{radioOption}] not checked") end } end |
#assert_text_in_element(elementID, text) ⇒ Object
46 47 48 49 50 |
# File 'lib/rwebunit/assert.rb', line 46 def assert_text_in_element(elementID, text) elem = element_by_id(elementID) assert_not_nil(elem.innerText, "element #{elementID} has no text") assert(elem.innerText.include?(text), "the text #{text} not found in element #{elementID}") end |
#assert_text_in_table(tableId, text) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/rwebunit/assert.rb', line 23 def assert_text_in_table(tableId, text) elem = element_by_id(tableId) assert_not_nil(elem, "tableId #{tableId} not exists") assert_equal(elem.tagName.upcase, "TABLE") puts elem.innerHTML if $DEBUG assert(elem.innerHTML.include?(text), "the text #{text} not found in table #{tableId}") end |
#assert_text_not_in_table(tableId, text) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/rwebunit/assert.rb', line 31 def assert_text_not_in_table(tableId, text) elem = element_by_id(tableId) assert_equal(elem.tagName.upcase, "TABLE") assert_not_nil(elem, "tableId #{tableId} not exists") assert(!elem.innerHTML.include?(text), "unexpected text #{text} found in table #{tableId}") end |
#assert_text_not_present(text) ⇒ Object
19 20 21 |
# File 'lib/rwebunit/assert.rb', line 19 def assert_text_not_present(text) assert(!(@web_tester.page_source.include? text), 'expected text: ' + text + ' found') end |
#assert_text_present(text) ⇒ Object
text
15 16 17 |
# File 'lib/rwebunit/assert.rb', line 15 def assert_text_present(text) assert((@web_tester.page_source.include? text), 'expected text: ' + text + ' not found') end |
#assert_text_present_in_text_field(textfieldName, text, msg = nil) ⇒ Object
219 220 221 222 223 224 225 |
# File 'lib/rwebunit/assert.rb', line 219 def assert_text_present_in_text_field(textfieldName, text, msg = nil) @web_tester.textfields.each { |textfield| if (textfield.name == textfieldName) then assert(text_field.value.include?(text), "text: #{text} not in text field: " + textfieldName) end } end |
#assert_title_equals(title) ⇒ Object
assertions
228 229 230 |
# File 'lib/rwebunit/assert.rb', line 228 def assert_title_equals(title) assert_equals(title, @web_tester.page_title) end |
#fail(message) ⇒ Object
244 245 246 |
# File 'lib/rwebunit/assert.rb', line 244 def fail() assert(false, ) end |