Alias for #assert_checkbox_not_selected
Checkbox
# File lib/rwebspec/assert.rb, line 86
86: def assert_checkbox_not_selected(checkbox_name)
87: @web_browser.checkboxes.each { |checkbox|
88: if (checkbox.name == checkbox_name) then
89: assert(!checkbox.isSet?, "Checkbox #{checkbox_name} is checked unexpectly")
90: end
91: }
92: end
(Not documented)
# File lib/rwebspec/assert.rb, line 95
95: def assert_checkbox_selected(checkbox_name)
96: @web_browser.checkboxes.each { |checkbox|
97: if (checkbox.name == checkbox_name) then
98: assert(checkbox.isSet?, "Checkbox #{checkbox_name} not checked")
99: end
100: }
101: end
(Not documented)
# File lib/rwebspec/assert.rb, line 236
236: def assert_equals(expected, actual, msg=nil)
237: assert(expected == actual, (msg.nil?) ? "Expected: #{expected} diff from actual: #{actual}" : msg)
238: end
Check a HTML element exists or not Example:
assert_exists("label", "receipt_date")
assert_exists(:span, :receipt_date)
# File lib/rwebspec/assert.rb, line 246
246: def assert_exists(tag, element_id) {}
247: begin
248: assert eval("#{tag}(:id, '#{element_id.to_s}').exists?")
249: rescue => e
250: raise "Element '#{tag}' with id: '#{element_id}' not found, #{e}"
251: end
252: end
(Not documented)
# File lib/rwebspec/assert.rb, line 59
59: def assert_link_not_present_with_exact(link_text)
60: @web_browser.links.each { |link|
61: assert(link_text != link.text, "unexpected link (exact): #{link_text} found")
62: }
63: end
(Not documented)
# File lib/rwebspec/assert.rb, line 77
77: def assert_link_not_present_with_text(link_text)
78: @web_browser.links.each { |link|
79: assert(!link.text.include?(link_text), "unexpected link containing: #{link_text} found")
80: }
81: end
Assert a link with specified text (exact match) in the page
<a href="">Click Me</a>
assert_link_present_with_exact("Click Me") => true
assert_link_present_with_exact("Click") => false
# File lib/rwebspec/assert.rb, line 52
52: def assert_link_present_with_exact(link_text)
53: @web_browser.links.each { |link|
54: return if link_text == link.text
55: }
56: fail( "can't find the link with text: #{link_text}")
57: end
Assert a link containing specified text in the page
<a href="">Click Me</a>
assert_link_present_with_text("Click ") # =>
# File lib/rwebspec/assert.rb, line 70
70: def assert_link_present_with_text(link_text)
71: @web_browser.links.each { |link|
72: return if link.text.include?(link_text)
73: }
74: fail( "can't find the link containing text: #{link_text}")
75: end
(Not documented)
# File lib/rwebspec/assert.rb, line 12
12: def assert_nil(actual, msg="")
13: assert(actual.nil?, msg)
14: end
(Not documented)
# File lib/rwebspec/assert.rb, line 8
8: def assert_not(condition, msg = "")
9: assert(!condition, msg)
10: end
(Not documented)
# File lib/rwebspec/assert.rb, line 256
256: def assert_not_exists(tag, element_id) {}
257: begin
258: assert_not eval("#{tag}(:id, '#{element_id.to_s}').exists?")
259: raise "Unexpected element'#{tag}' + with id: '#{element_id}' found"
260: rescue => e
261: end
262: end
(Not documented)
# File lib/rwebspec/assert.rb, line 16
16: def assert_not_nil(actual, msg="")
17: assert(!actual.nil?, msg)
18: end
(Not documented)
# File lib/rwebspec/assert.rb, line 148
148: def assert_option_equals(select_name, option_label)
149: @web_browser.select_lists.each { |select|
150: next unless select.name == select_name
151: select.o.each do |option| # items in the list
152: if (option.text == option_label) then
153: assert_equal(select.value, option.value, "Select #{select_name}'s value is not equal to expected option label: '#{option_label}'")
154: end
155: end
156: }
157: end
(Not documented)
# File lib/rwebspec/assert.rb, line 116
116: def assert_option_not_present(select_name, option_label)
117: @web_browser.select_lists.each { |select|
118: next unless select.name == select_name
119: select.o.each do |option| # items in the list
120: assert(!(option.text == option_label), "unexpected select option: #{option_label} for #{select_name} found")
121: end
122: }
123: end
(Not documented)
# File lib/rwebspec/assert.rb, line 137
137: def assert_option_present(select_name, option_label)
138: @web_browser.select_lists.each { |select|
139: next unless select.name == select_name
140: select.o.each do |option| # items in the list
141: return if option.text == option_label
142: end
143: }
144: assert(false, "can't find the combob box: #{select_name} with value: #{option_label}")
145: end
(Not documented)
# File lib/rwebspec/assert.rb, line 160
160: def assert_option_value_equals(select_name, option_value)
161: @web_browser.select_lists.each { |select|
162: next unless select.name == select_name
163: assert_equal(select.value, option_value, "Select #{select_name}'s value is not equal to expected: '#{option_value}'")
164: }
165: end
select
# File lib/rwebspec/assert.rb, line 106
106: def assert_option_value_not_present(select_name, option_value)
107: @web_browser.select_lists.each { |select|
108: continue unless select.name == select_name
109: select.o.each do |option| # items in the list
110: assert(!(option.value == option_value), "unexpected select option: #{option_value} for #{select_name} found")
111: end
112: }
113: end
(Not documented)
# File lib/rwebspec/assert.rb, line 126
126: def assert_option_value_present(select_name, option_value)
127: @web_browser.select_lists.each { |select|
128: next unless select.name == select_name
129: select.o.each do |option| # items in the list
130: return if option.value == option_value
131: end
132: }
133: assert(false, "can't find the combob box with value: #{option_value}")
134: end
Alias for #assert_radio_option_selected
Alias for #assert_radio_option_not_selected
radio_group is the name field, radio options ‘value’ field
# File lib/rwebspec/assert.rb, line 172
172: def assert_radio_option_not_present(radio_group, radio_option)
173: @web_browser.radios.each { |radio|
174: if (radio.name == radio_group) then
175: assert(!(radio_option == radio.value), "unexpected radio option: " + radio_option + " found")
176: end
177: }
178: end
(Not documented)
# File lib/rwebspec/assert.rb, line 197
197: def assert_radio_option_not_selected(radio_group, radio_option)
198: @web_browser.radios.each { |radio|
199: if (radio.name == radio_group and radio_option == radio.value) then
200: assert(!radio.isSet?, "Radio button #{radio_group}-[#{radio_option}] checked unexpected")
201: end
202: }
203: end
(Not documented)
# File lib/rwebspec/assert.rb, line 180
180: def assert_radio_option_present(radio_group, radio_option)
181: @web_browser.radios.each { |radio|
182: return if (radio.name == radio_group) and (radio_option == radio.value)
183: }
184: fail("can't find the radio option : '#{radio_option}'")
185: end
(Not documented)
# File lib/rwebspec/assert.rb, line 187
187: def assert_radio_option_selected(radio_group, radio_option)
188: @web_browser.radios.each { |radio|
189: if (radio.name == radio_group and radio_option == radio.value) then
190: assert(radio.isSet?, "Radio button #{radio_group}-[#{radio_option}] not checked")
191: end
192: }
193: end
Alias for #assert_option_equals
Alias for #assert_option_not_present
Alias for #assert_option_present
Alias for #assert_option_value_equals
Alias for #assert_option_value_not_present
Alias for #assert_option_value_present
Assert a text field (with given name) has the value
assert_text_field_value(“text1”, “text already there”) => true
# File lib/rwebspec/assert.rb, line 330
330: def assert_text_field_value(textfield_name, text)
331: assert_equal(text, text_field(:name, textfield_name).value)
332: end
— Not tested
-----
# File lib/rwebspec/assert.rb, line 338
338: def assert_text_in_element(element_id, text)
339: elem = element_by_id(element_id)
340: assert_not_nil(elem.innerText, "element #{element_id} has no text")
341: assert(elem.innerText.include?(text), "the text #{text} not found in element #{element_id}")
342: end
Alias for #assert_text_present_in_table
Alias for #assert_text_not_present_in_table
Assert text not present in page source (html)
assert_text_not_present("<h1>iTest2</h1>")
# File lib/rwebspec/assert.rb, line 38
38: def assert_text_not_present(text)
39: assert(!(@web_browser.page_source.include? text), 'expected text: ' + text + ' found')
40: end
(Not documented)
# File lib/rwebspec/assert.rb, line 319
319: def assert_text_not_present_in_table(table_id, text, options = { :just_plain_text => false })
320: assert_not(table_source(table_id, options).include?(text), "the text #{text} not found in table #{table_id}")
321: end
Assert text present in page source (html)
assert_text_present("<h1>iTest2</h1>")
# File lib/rwebspec/assert.rb, line 32
32: def assert_text_present(text)
33: assert((@web_browser.page_source.include? text), 'expected text: ' + text + ' not found')
34: end
Assert given text appear inside a table (inside
The plain text view of above table
A B a b
Examples
assert_text_present_in_table("t1", ">A<") # => true
assert_text_present_in_table("t1", ">A<", :just_plain_text => true) # => false
# File lib/rwebspec/assert.rb, line 314
314: def assert_text_present_in_table(table_id, text, options = { :just_plain_text => false })
315: assert(table_source(table_id, options).include?(text), "the text #{text} not found in table #{table_id}")
316: end
assertions
# File lib/rwebspec/assert.rb, line 25
25: def assert_title_equals(title)
26: assert_equals(title, @web_browser.page_title)
27: end
Assert tag with element id is visible?, eg.
assert_visible(:div, "public_notice") assert_visible(:span, "public_span")
# File lib/rwebspec/assert.rb, line 270
270: def assert_visible(tag, element_id)
271: begin
272: assert(eval("#{tag}(:id, '#{element_id.to_s}').visible?"))
273: rescue => e
274: raise "Element '#{tag}' with id: '#{element_id}' not visible, #{e}"
275: end
276: end
(Not documented)
# File lib/rwebspec/assert.rb, line 20
20: def fail(message)
21: assert(false, message)
22: end
TODO for drag-n-drop, check the postion in list
def assert_position_in_list(list_element_id)
raise "not implemented"
end
# File lib/rwebspec/assert.rb, line 353
353: def table_source(table_id, options)
354: elem_table = table(:id, table_id.to_s)
355: elem_table_text = elem_table.text
356: elem_table_html = is_firefox? ? elem_table.innerHTML : elem_table.html
357: table_source = options[:just_plain_text] ? elem_table_text : elem_table_html
358: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.