Module: SitePrism::ElementChecker

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

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 { element => :button_one, element => :button_two, section => :filters } @my_page.all_there?

> true - If the three 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)

23
24
25
26
27
28
29
30
31
32
# File 'lib/site_prism/element_checker.rb', line 23

def all_there?(recursion: :none)
  if recursion == :none
    elements_to_check.all? { |name| there?(name) }
  elsif recursion == :one
    all_there_with_recursion
  else
    SitePrism.logger.debug("Input value '#{recursion}'. Valid values are :none or :one.")
    SitePrism.logger.error('Invalid recursion setting, Will not run #all_there?.')
  end
end

#elements_presentObject


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

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