Skip to content

Commit

Permalink
Fix exceptions and exception strings for negative tests
Browse files Browse the repository at this point in the history
  • Loading branch information
semperos committed Jan 27, 2011
1 parent afe6033 commit ba38dba
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 32 deletions.
2 changes: 1 addition & 1 deletion lib/watir_robot/keywords/checkbox.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def checkbox_should_be_selected(loc)
# @param [String] loc attribute/value pairs that match an HTML element
#
def checkbox_should_not_be_selected(loc)
raise(Exception::CheckboxSelectionError, "The checkbox located at #{loc} is checked off.") if
raise(Exception::CheckboxSelectionError, "The checkbox located at #{loc} is checked off erroneously.") if
@browser.checkbox(parse_location(loc)).set?
end

Expand Down
8 changes: 4 additions & 4 deletions lib/watir_robot/keywords/element.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def focus(loc)
# @param [String] loc attribute/value pairs that match an HTML element
#
def element_should_be_visible(loc)
raise(Exception::ElementVisibilityError, "The element described by #{parse_location(loc)} is not visible") unless
raise(Exception::ElementVisibilityError, "The element described by #{parse_location(loc)} is not visible.") unless
@browser.element(parse_location(loc)).visible?
end

Expand All @@ -64,7 +64,7 @@ def element_should_be_visible(loc)
# @param [String] loc attribute/value pairs that match an HTML element
#
def element_should_not_be_visible(loc)
raise(Exception::ElementVisibilityError, "The element described by #{parse_location(loc)} is not visible") if
raise(Exception::ElementVisibilityError, "The element described by #{parse_location(loc)} is visible erroneously.") if
@browser.element(parse_location(loc)).visible?
end

Expand All @@ -75,7 +75,7 @@ def element_should_not_be_visible(loc)
# @param [String] text the text to compare against
#
def element_text_should_contain(loc, text)
raise(Exception::ElementMatchError, "The element's text #{@browser.element(parse_location(loc)).text} does not contain the text #{text}") unless
raise(Exception::ElementMatchError, "The element's text #{@browser.element(parse_location(loc)).text} does not contain the text #{text}.") unless
@browser.element(parse_location(loc)).text.include? text
end

Expand All @@ -85,7 +85,7 @@ def element_text_should_contain(loc, text)
# @param [String] text the text to compare against
#
def element_text_should_be(loc, text)
raise(Exception::ElementMatchError, "The element's text #{@browser.element(parse_location(loc)).text} does not equal #{text}") unless
raise(Exception::ElementMatchError, "The element's text #{@browser.element(parse_location(loc)).text} does not equal #{text}.") unless
@browser.element(parse_location(loc)).text == text
end

Expand Down
24 changes: 12 additions & 12 deletions lib/watir_robot/keywords/form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module Form
# @param [String] field_loc attribute/value pairs that match an HTML element
#
def form_should_contain_button(form_loc, field_loc)
raise(Exception::ElementMatchError, "The button described by #{field_loc} was not located in the form described by #{form_loc}") unless
raise(Exception::ElementMatchError, "The button described by #{field_loc} was not located in the form described by #{form_loc}.") unless
@browser.form(parse_location(form_loc)).button(parse_location(field_loc)).exists?
end

Expand All @@ -23,7 +23,7 @@ def form_should_contain_button(form_loc, field_loc)
# @param [String] field_loc attribute/value pairs that match an HTML element
#
def form_should_not_contain_button(form_loc, field_loc)
raise(Exception::ElementMatchError, "The button described by #{field_loc} was not located in the form described by #{form_loc}") if
raise(Exception::ElementMatchError, "The button described by #{field_loc} was erroneously located in the form described by #{form_loc}.") if
@browser.form(parse_location(form_loc)).button(parse_location(field_loc)).exists?
end

Expand All @@ -34,7 +34,7 @@ def form_should_not_contain_button(form_loc, field_loc)
# @param [String] field_loc attribute/value pairs that match an HTML element
#
def form_should_contain_checkbox(form_loc, field_loc)
raise(Exception::ElementMatchError, "The checkbox described by #{field_loc} was not located in the form described by #{form_loc}") unless
raise(Exception::ElementMatchError, "The checkbox described by #{field_loc} was not located in the form described by #{form_loc}.") unless
@browser.form(parse_location(form_loc)).checkbox(parse_location(field_loc)).exists?
end

Expand All @@ -45,7 +45,7 @@ def form_should_contain_checkbox(form_loc, field_loc)
# @param [String] field_loc attribute/value pairs that match an HTML element
#
def form_should_not_contain_checkbox(form_loc, field_loc)
raise(Exception::ElementMatchError, "The checkbox described by #{field_loc} was not located in the form described by #{form_loc}") if
raise(Exception::ElementMatchError, "The checkbox described by #{field_loc} was erroneously located in the form described by #{form_loc}.") if
@browser.form(parse_location(form_loc)).checkbox(parse_location(field_loc)).exists?
end

Expand All @@ -56,7 +56,7 @@ def form_should_not_contain_checkbox(form_loc, field_loc)
# @param [String] field_loc attribute/value pairs that match an HTML element
#
def form_should_contain_filefield(form_loc, field_loc)
raise(Exception::ElementMatchError, "The file-field described by #{field_loc} was not located in the form described by #{form_loc}") unless
raise(Exception::ElementMatchError, "The file-field described by #{field_loc} was not located in the form described by #{form_loc}.") unless
@browser.form(parse_location(form_loc)).file_field(parse_location(field_loc)).exists?
end

Expand All @@ -67,7 +67,7 @@ def form_should_contain_filefield(form_loc, field_loc)
# @param [String] field_loc attribute/value pairs that match an HTML element
#
def form_should_not_contain_filefield(form_loc, field_loc)
raise(Exception::ElementMatchError, "The file-field described by #{field_loc} was not located in the form described by #{form_loc}") if
raise(Exception::ElementMatchError, "The file-field described by #{field_loc} was erroneously located in the form described by #{form_loc}.") if
@browser.form(parse_location(form_loc)).file_field(parse_location(field_loc)).exists?
end

Expand All @@ -78,7 +78,7 @@ def form_should_not_contain_filefield(form_loc, field_loc)
# @param [String] field_loc attribute/value pairs that match an HTML element
#
def form_should_contain_radio_button(form_loc, field_loc)
raise(Exception::ElementMatchError, "The radio button described by #{field_loc} was not located in the form described by #{form_loc}") unless
raise(Exception::ElementMatchError, "The radio button described by #{field_loc} was not located in the form described by #{form_loc}.") unless
@browser.form(parse_location(form_loc)).radio(parse_location(field_loc)).exists?
end

Expand All @@ -89,7 +89,7 @@ def form_should_contain_radio_button(form_loc, field_loc)
# @param [String] field_loc attribute/value pairs that match an HTML element
#
def form_should_not_contain_radio_button(form_loc, field_loc)
raise(Exception::ElementMatchError, "The radio button described by #{field_loc} was not located in the form described by #{form_loc}") if
raise(Exception::ElementMatchError, "The radio button described by #{field_loc} was erroneously located in the form described by #{form_loc}.") if
@browser.form(parse_location(form_loc)).radio(parse_location(field_loc)).exists?
end

Expand All @@ -100,7 +100,7 @@ def form_should_not_contain_radio_button(form_loc, field_loc)
# @param [String] field_loc attribute/value pairs that match an HTML element
#
def form_should_contain_select_list(form_loc, field_loc)
raise(Exception::ElementMatchError, "The select list described by #{field_loc} was not located in the form described by #{form_loc}") unless
raise(Exception::ElementMatchError, "The select list described by #{field_loc} was not located in the form described by #{form_loc}.") unless
@browser.form(parse_location(form_loc)).select(parse_location(field_loc)).exists?
end

Expand All @@ -111,7 +111,7 @@ def form_should_contain_select_list(form_loc, field_loc)
# @param [String] field_loc attribute/value pairs that match an HTML element
#
def form_should_not_contain_select_list(form_loc, field_loc)
raise(Exception::ElementMatchError, "The select list described by #{field_loc} was not located in the form described by #{form_loc}") if
raise(Exception::ElementMatchError, "The select list described by #{field_loc} was erroneously located in the form described by #{form_loc}.") if
@browser.form(parse_location(form_loc)).select(parse_location(field_loc)).exists?
end

Expand All @@ -122,7 +122,7 @@ def form_should_not_contain_select_list(form_loc, field_loc)
# @param [String] field_loc attribute/value pairs that match an HTML element
#
def form_should_contain_textfield(form_loc, field_loc)
raise(Exception::ElementMatchError, "The textfield described by #{field_loc} was not located in the form described by #{form_loc}") unless
raise(Exception::ElementMatchError, "The textfield described by #{field_loc} was not located in the form described by #{form_loc}.") unless
@browser.form(parse_location(form_loc)).text_field(parse_location(field_loc)).exists?
end

Expand All @@ -133,7 +133,7 @@ def form_should_contain_textfield(form_loc, field_loc)
# @param [String] field_loc attribute/value pairs that match an HTML element
#
def form_should_not_contain_textfield(form_loc, field_loc)
raise(Exception::ElementMatchError, "The textfield described by #{field_loc} was not located in the form described by #{form_loc}") if
raise(Exception::ElementMatchError, "The textfield described by #{field_loc} was erroneously located in the form described by #{form_loc}.") if
@browser.form(parse_location(form_loc)).text_field(parse_location(field_loc)).exists?
end

Expand Down
24 changes: 12 additions & 12 deletions lib/watir_robot/keywords/page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def page_should_contain(text)
# @param [String] text the text to compare against
#
def page_should_not_contain(text)
raise(Exception::PageMatchError, "The expected text #{text} was not contained in the page: #{@browser.text}") if
raise(Exception::PageMatchError, "The expected text #{text} was contained in the page erroneously: #{@browser.text}") if
@browser.text.include? text
end

Expand All @@ -110,7 +110,7 @@ def page_should_contain_area(loc)
# @param [String] loc attribute/value pairs that match an HTML element
#
def page_should_not_contain_area(loc)
raise(Exception::ElementExists, "The area described by #{loc} is not contained within the page:\n#{@browser.html}") if
raise(Exception::ElementExists, "The area described by #{loc} is erroneously contained within the page:\n#{@browser.html}") if
@browser.area(parse_location(loc)).exists?
end

Expand Down Expand Up @@ -150,7 +150,7 @@ def page_should_contain_checkbox(loc)
# @param [String] loc attribute/value pairs that match an HTML element
#
def page_should_not_contain_checkbox(loc)
raise(Exception::ElementDoesNotExist, "The checkbox described by #{loc} is not contained within the page:\n#{@browser.html}") if
raise(Exception::ElementExists, "The checkbox described by #{loc} is erroneously contained within the page:\n#{@browser.html}") if
@browser.checkbox(parse_location(loc)).exists?
end

Expand All @@ -170,7 +170,7 @@ def page_should_contain_element(loc)
# @param [String] loc attribute/value pairs that match an HTML element
#
def page_should_not_contain_element(loc)
raise(Exception::ElementDoesNotExist, "The element described by #{loc} is not contained within the page:\n#{@browser.html}") if
raise(Exception::ElementExists, "The element described by #{loc} is erroneously contained within the page:\n#{@browser.html}") if
@browser.element(parse_location(loc)).exists?
end

Expand All @@ -190,7 +190,7 @@ def page_should_contain_image(loc)
# @param [String] loc attribute/value pairs that match an HTML element
#
def page_should_not_contain_image(loc)
raise(Exception::ElementDoesNotExist, "The image described by #{loc} is not contained within the page:\n#{@browser.html}") if
raise(Exception::ElementExists, "The image described by #{loc} is erroneously contained within the page:\n#{@browser.html}") if
@browser.image(parse_location(loc)).exists?
end

Expand All @@ -210,7 +210,7 @@ def page_should_contain_link(loc)
# @param [String] loc attribute/value pairs that match an HTML element
#
def page_should_not_contain_link(loc)
raise(Exception::ElementDoesNotExist, "The link described by #{loc} is not contained within the page:\n#{@browser.html}") if
raise(Exception::ElementExists, "The link described by #{loc} is erroneously contained within the page:\n#{@browser.html}") if
@browser.link(parse_location(loc)).exists?
end

Expand Down Expand Up @@ -247,13 +247,13 @@ def page_should_not_contain_list(loc, ordered = nil)
ordered = ordered.downcase unless ordered == nil
if ordered.nil?
# Not specified; match either
raise(Exception::ElementDoesNotExist, "The list described by #{loc} is not contained within the page:\n#{@browser.html}") if
raise(Exception::ElementExists, "The list described by #{loc} is erroneously contained within the page:\n#{@browser.html}") if
(@browser.ol(parse_location(loc)).exists? || @browser.ul(parse_location(loc)).exists?)
elsif ordered == 'true'
raise(Exception::ElementDoesNotExist, "The ordered list described by #{loc} is not contained within the page:\n#{@browser.html}") if
raise(Exception::ElementExists, "The ordered list described by #{loc} is erroneously contained within the page:\n#{@browser.html}") if
@browser.ol(parse_location(loc)).exists?
elsif ordered == 'false'
raise(Exception::ElementDoesNotExist, "The unordered list described by #{loc} is not contained within the page:\n#{@browser.html}") if
raise(Exception::ElementExists, "The unordered list described by #{loc} is erroneously contained within the page:\n#{@browser.html}") if
@browser.ul(parse_location(loc)).exists?
else
raise(ArgumentError, "If you specify ordered vs. unordered lists, the only valid values are 'true' or 'false' (case-insensitive)")
Expand All @@ -276,7 +276,7 @@ def page_should_contain_radio_button(loc)
# @param [String] loc attribute/value pairs that match an HTML element
#
def page_should_not_contain_radio_button(loc)
raise(Exception::ElementDoesNotExist, "The radio button described by #{loc} is not contained within the page:\n#{@browser.html}") if
raise(Exception::ElementExists, "The radio button described by #{loc} is erroneously contained within the page:\n#{@browser.html}") if
@browser.radio(parse_location(loc)).exists?
end

Expand All @@ -296,7 +296,7 @@ def page_should_contain_select_list(loc)
# @param [String] loc attribute/value pairs that match an HTML element
#
def page_should_not_contain_select_list(loc)
raise(Exception::ElementDoesNotExist, "The select list described by #{loc} is not contained within the page:\n#{@browser.html}") if
raise(Exception::ElementExists, "The select list described by #{loc} is not contained within the page erroneously:\n#{@browser.html}") if
@browser.select(parse_location(loc)).exists?
end

Expand All @@ -316,7 +316,7 @@ def page_should_contain_textfield(loc)
# @param [String] loc attribute/value pairs that match an HTML element
#
def page_should_not_contain_textfield(loc)
raise(Exception::ElementDoesNotExist, "The text field described by #{loc} is not contained within the page:\n#{@browser.html}") if
raise(Exception::ElementExists, "The text field described by #{loc} is not contained within the page erroneously:\n#{@browser.html}") if
@browser.text_field(parse_location(loc)).exists?
end

Expand Down
2 changes: 1 addition & 1 deletion lib/watir_robot/keywords/radio.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def radio_button_should_be_selected(loc)
# @param [String] loc attribute/value pairs that match an HTML element
#
def radio_button_should_not_be_selected(loc)
raise(Exception::RadioSelectionError, "The radio button located at #{loc} is selected.") if
raise(Exception::RadioSelectionError, "The radio button located at #{loc} is selected erroneously.") if
@browser.radio(parse_location(loc)).set?
end

Expand Down
4 changes: 2 additions & 2 deletions lib/watir_robot/keywords/select.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def clear_items_from_list(loc)
# @param [String] item_loc attribute/value pairs that match an item in a select list
#
def item_should_be_selected(list_loc, item_loc)
raise(Exception::SelectListSelectionError, "The item described by #{item_loc} in the select list described by #{list_loc} is not selected") unless
raise(Exception::SelectListSelectionError, "The item described by #{item_loc} in the select list described by #{list_loc} is not selected.") unless
@browser.select(parse_location(list_loc)).option(parse_location(item_loc)).selected?
end

Expand All @@ -73,7 +73,7 @@ def item_should_be_selected(list_loc, item_loc)
# @param [String] item_loc attribute/value pairs that match an item in a select list
#
def item_should_not_be_selected(list_loc, item_loc)
raise(Exception::SelectListSelectionError, "The item described by #{item_loc} in the select list described by #{list_loc} is selected") if
raise(Exception::SelectListSelectionError, "The item described by #{item_loc} in the select list described by #{list_loc} is selected erroneously.") if
@browser.select(parse_location(list_loc)).option(parse_location(item_loc)).selected?
end

Expand Down

0 comments on commit ba38dba

Please sign in to comment.