Module: Watir::RSpec::Matchers

Defined in:
lib/watir/rspec/matchers.rb,
lib/watir/rspec/matchers/base_matcher.rb

Overview

All matchers defined in here have the ability to be used for asynchronous testing.

#within matcher means that the expected result should happen within the specified time period.

Also less used #during matcher which means that the expected result should be true for the whole specified time period.

Examples:

Wait for 2 seconds until element is present (element exists and is visible)

expect(text_field).to be_present.within(2)

Wait for 2 seconds until element is visible

expect(text_field).to be_visible.within(2)

Wait for 2 seconds until element exists

expect(text_field).to exist.within(2)

Verify that container is visible for the whole time during 2 seconds

button.click
expect(text_field).to be_visible.during(2)

Instance Method Summary collapse

Instance Method Details

#be_present



25
26
27
# File 'lib/watir/rspec/matchers.rb', line 25

def be_present
  BaseMatcher.new :present?
end

#be_visible



29
30
31
# File 'lib/watir/rspec/matchers.rb', line 29

def be_visible
  BaseMatcher.new :visible?
end

#exist



33
34
35
# File 'lib/watir/rspec/matchers.rb', line 33

def exist
  BaseMatcher.new :exist?
end