Class: Spec::Watir::HaveTextField

Inherits:
Object
  • Object
show all
Defined in:
lib/spec/ui/watir_helper.rb

Overview

:nodoc

Instance Method Summary collapse

Constructor Details

#initialize(how, what) ⇒ HaveTextField

Returns a new instance of HaveTextField.



143
144
145
# File 'lib/spec/ui/watir_helper.rb', line 143

def initialize(how, what)
  @how, @what = how, what
end

Instance Method Details

#failure_messageObject



158
159
160
# File 'lib/spec/ui/watir_helper.rb', line 158

def failure_message
  "Expected browser to have text_field(#{@how}, #{@what}), but it was not found"
end

#matches?(browser) ⇒ Boolean

Returns:

  • (Boolean)


147
148
149
150
151
152
153
154
155
156
# File 'lib/spec/ui/watir_helper.rb', line 147

def matches?(browser)
  @browser = browser
  begin
    text_field = @browser.text_field(@how, @what)
    text_field.assert_exists
    true
  rescue ::Watir::Exception::UnknownObjectException => e
    false
  end
end

#negative_failure_messageObject



162
163
164
# File 'lib/spec/ui/watir_helper.rb', line 162

def negative_failure_message
  "Expected browser not to have text_field(#{@how}, #{@what}), but it was found"
end