Module: Watirmark::Controller::Assertions
- Included in:
- Watirmark::Controller
- Defined in:
- lib/watirmark/controller/assertions.rb
Instance Method Summary (collapse)
-
- (Object) actual_value(element, expected = nil)
Returns the user visible value of the element.
- - (Object) assert(result)
- - (Object) assert_equal(element, expected)
- - (Object) compare_values(element, expected, actual)
Instance Method Details
- (Object) actual_value(element, expected = nil)
Returns the user visible value of the element.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/watirmark/controller/assertions.rb', line 22 def actual_value element, expected=nil case element when Watir::SelectList element.getSelectedItems[0] when Watir::CheckBox element.isSet? when Watir::Radio if element.valueIsSet?(expected) expected else element.value # not really correct, but the best we can do right now end when Watir::TextField element.value else if element.value != '' element.value else element.text end end end |
- (Object) assert(result)
45 46 47 48 49 |
# File 'lib/watirmark/controller/assertions.rb', line 45 def assert(result) if result != true raise Watirmark::VerificationException, "Expected true got #{result}" end end |
- (Object) assert_equal(element, expected)
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/watirmark/controller/assertions.rb', line 6 def assert_equal(element, expected) return if expected.nil? element.extend KeywordElementMethods if map = element.radio_map expected = map.lookup(expected) end # Get the actual value if element.exists? actual = actual_value element, expected end compare_values(element, expected, actual) end |
- (Object) compare_values(element, expected, actual)
51 52 53 54 55 56 57 58 59 |
# File 'lib/watirmark/controller/assertions.rb', line 51 def compare_values(element, expected, actual) @matcher ||= Watirmark::Matcher.new if !@matcher.matches(element, expected, actual) error = Watirmark::VerificationException.new(@matcher.) error.actual = actual error.expected = expected raise error end end |