Module: SeleniumRecord::Axis

Included in:
Base
Defined in:
lib/selenium_record/axis.rb

Overview

Helper methods for comparing the relative position in DOM among selenium objects

Instance Method Summary collapse

Instance Method Details

#after?(other_view) ⇒ Boolean

Returns Marks whether the current view is located in DOM after the view passed as parameter.

Parameters:

Returns:

  • (Boolean)

    Marks whether the current view is located in DOM after the view passed as parameter



8
9
10
# File 'lib/selenium_record/axis.rb', line 8

def after?(other_view)
  preceding_sibling_elements.member? other_view.root_el
end

#before?(other_view) ⇒ Boolean

Returns Marks whether the current view is located in DOM before the view passed as parameter.

Parameters:

Returns:

  • (Boolean)

    Marks whether the current view is located in DOM before the view passed as parameter



15
16
17
# File 'lib/selenium_record/axis.rb', line 15

def before?(other_view)
  following_sibling_elements.member? other_view.root_el
end

#following_sibling_elementsArray<Selenium::WebDriver::Element>

Returns all elements belonging to following sibling xpath axe

Returns:

  • (Array<Selenium::WebDriver::Element>)


38
39
40
# File 'lib/selenium_record/axis.rb', line 38

def following_sibling_elements
  find_elements(following_sibling_locator)
end

#ordered?(*models) ⇒ Boolean

Returns Marks whether the model views are ordered in the dom.

Parameters:

  • models (Array<PORO>)

    list of models associated to views

Returns:

  • (Boolean)

    Marks whether the model views are ordered in the dom



21
22
23
24
25
26
27
28
# File 'lib/selenium_record/axis.rb', line 21

def ordered?(*models)
  result = []
  models.reduce(nil) do |prev, current|
    result << (view_for(prev).before? view_for(current)) if prev
    current
  end
  result.any?
end

#preceding_sibling_elementsArray<Selenium::WebDriver::Element>

Returns all elements belonging to preceding sibling xpath axe

Returns:

  • (Array<Selenium::WebDriver::Element>)


32
33
34
# File 'lib/selenium_record/axis.rb', line 32

def preceding_sibling_elements
  find_elements(preceding_sibling_locator)
end