Module: SitePrism::ElementChecker

Included in:
Page, Section
Defined in:
lib/site_prism/element_checker.rb

Overview

SitePrism::ElementChecker

This allows users to run ‘#all_there?` checks on an instance.

Instance Method Summary collapse

Instance Method Details

#all_there?(recursion: :none) ⇒ Boolean

Runnable in the scope of any SitePrism::Page or Section. Returns true when “every item” that is being checked is present within the current scope. See #elements_to_check for how the definition of “every item” is derived.

Example ‘@my_page.class.mapped_items`

{
  element => [:button_one, :button_two],
  elements => [:button_collection_one, :button_collection_two],
  section => [:filters],
  sections => [:search_result],
  iframe => []
}

‘@my_page.all_there?`

> true - If the items above are all present

Note that #elements_to_check will check the hash of mapped_items

When using the recursion parameter, one of two values is valid.

Default: ‘none’ => Perform no recursion when calling #all_there? Override: ‘one’ => Perform one recursive dive into all section/sections items and call #all_there? on all of those items too.

Returns:

  • (Boolean)


34
35
36
# File 'lib/site_prism/element_checker.rb', line 34

def all_there?(recursion: :none)
  SitePrism::AllThere::RecursionChecker.new(self).all_there?(recursion: recursion)
end

#elements_missingArray

Returns each element that is not currently present inside the scope being tested

Returns:

  • (Array)


48
49
50
# File 'lib/site_prism/element_checker.rb', line 48

def elements_missing
  elements_to_check.reject { |name| there?(name) }
end

#elements_presentArray

Returns each element that is currently present inside the scope being tested

Returns:

  • (Array)


41
42
43
# File 'lib/site_prism/element_checker.rb', line 41

def elements_present
  elements_to_check.select { |name| there?(name) }
end