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
-
#after?(other_view) ⇒ Boolean
Marks whether the current view is located in DOM after the view passed as parameter.
-
#before?(other_view) ⇒ Boolean
Marks whether the current view is located in DOM before the view passed as parameter.
-
#following_sibling_elements ⇒ Array<Selenium::WebDriver::Element>
Returns all elements belonging to following sibling xpath axe.
-
#ordered?(*models) ⇒ Boolean
Marks whether the model views are ordered in the dom.
-
#preceding_sibling_elements ⇒ Array<Selenium::WebDriver::Element>
Returns all elements belonging to preceding sibling xpath axe.
Instance Method Details
#after?(other_view) ⇒ Boolean
Returns 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.
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_elements ⇒ Array<Selenium::WebDriver::Element>
Returns all elements belonging to following sibling xpath axe
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.
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_elements ⇒ Array<Selenium::WebDriver::Element>
Returns all elements belonging to preceding sibling xpath axe
32 33 34 |
# File 'lib/selenium_record/axis.rb', line 32 def preceding_sibling_elements find_elements(preceding_sibling_locator) end |