Module: FieldUtils
- Defined in:
- lib/FieldUtils.rb
Overview
FieldUtils – Module
This is a module that is for things that only have to deal with
SodaFields.
Class Method Summary collapse
-
.CheckDisabled(field, expected, reporter) ⇒ Object
CheckDisabled – function This function checks that a given elements disabled status matches the expected status, and reports on the findings.
-
.WatirFieldToStr(field, reporter) ⇒ Object
WatirFieldToStr – function This function creates a simple string from the inspect info for a watir element.
Class Method Details
.CheckDisabled(field, expected, reporter) ⇒ Object
CheckDisabled – function
This function checks that a given elements disabled status matches the
expected status, and reports on the findings.
Input:
field: this is the watir element object to check the status of.
expected: bool, this is the status that is expected.
reporter: A SodaReporter object.
Output:
Always returns 0.
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/FieldUtils.rb', line 84 def FieldUtils.CheckDisabled(field, expected, reporter) element_status = field.disabled() tmp = FieldUtils.WatirFieldToStr(field, reporter) if (element_status != expected) msg = "Expected element: #{tmp} state to be disabled = "+ "'#{expected}'"+ ", but found element to be disabled = '#{element_status}'!\n" reporter.ReportFailure(msg) else msg = "Element: #{tmp} state is disabled = '#{element_status}' as "+ "expected.\n" reporter.log(msg) end return 0 end |
.WatirFieldToStr(field, reporter) ⇒ Object
WatirFieldToStr – function
This function creates a simple string from the inspect info for a
watir element.
Input:
field: A watir element object.
reporter: A SodaReporter object.
Output:
returns a string with inspect info in it, on nil on error.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/FieldUtils.rb', line 48 def FieldUtils.WatirFieldToStr(field, reporter) info = nil msg = "" elm_type = nil begin info = field.inspect() info = info.chomp() info =~ /#\<\w+::(\w+):/ elm_type = "#{$1}" msg << "#{elm_type}:" info =~ /how=(\{.*\})/i msg << " #{$1}" rescue Exception => e reporter.ReportException(e, true) msg = nil ensure end return msg end |