Module: QAT::Web::Finders

Includes:
Configuration
Included in:
ProjectName::Web::Pages::Base
Defined in:
lib/qat/web/finders.rb

Overview

Module with custom finders based on configuration since 1.0.0

Instance Method Summary collapse

Methods included from Configuration

last_access, #last_access, last_access=, #parse_configuration

Instance Method Details

#find_from_configuration(config) ⇒ Capybara::Session

Alias to Capybara::Node::Finders#find method with parameter loading from configuration. An Hash should be provided to calculate the correct parameters to pass to the original find method.

Parameters:

  • config (Hash)

    Configuration to extract parameters from

Options Hash (config):

  • :type (String)

    Selector type (Capybara.default_selector)

  • :value (String)

    Selector value

Returns:

  • (Capybara::Session)

    Current session

See Also:

  • Capybara::Node::Finders#find
  • Capybara::Queries::SelectorQuery

Since:

  • 1.0.0



19
20
21
22
# File 'lib/qat/web/finders.rb', line 19

def find_from_configuration config
  type, value, opts = parse_configuration config
  page.find type, value, opts
end

#pageCapybara::Session

Alias to Capybara::DSL base method

Returns:

  • (Capybara::Session)

    Current session

Since:

  • 1.0.0



41
42
43
# File 'lib/qat/web/finders.rb', line 41

def page
  Capybara.current_session
end

#within_from_configuration(config, &block) ⇒ Capybara::Session

Alias to Capybara::Node::Finders#within method with parameter loading from configuration. An Hash should be provided to calculate the correct parameters to pass to the original within method.

Parameters:

  • config (Hash)

    Configuration to extract parameters from

Options Hash (config):

  • :type (String)

    Selector type (Capybara.default_selector)

  • :value (String)

    Selector value

Returns:

  • (Capybara::Session)

    Current session

See Also:

  • Capybara::Node::Finders#find
  • Capybara::Queries::SelectorQuery

Since:

  • 1.0.0



33
34
35
36
# File 'lib/qat/web/finders.rb', line 33

def within_from_configuration config, &block
  type, value, opts = parse_configuration config
  page.within type.to_sym, value, opts, &block
end