Class: JQueryUIWidgets::Accordion

Inherits:
PageObject::Elements::Div
  • Object
show all
Defined in:
lib/jqueryui_widgets/accordion.rb

Overview

Accordion class to make use of the Accordion widget.

NOTE: Since JQueryUI Widgets are completely customizable, we’ve kept the Accordion class limited to basic functionality so that end users can pick up the gem and customize it to suit their own needs.

Instance Method Summary collapse

Instance Method Details

#labelsObject

labels method will map all of the headers in the accordion to an array to allow for comparison.



63
64
65
# File 'lib/jqueryui_widgets/accordion.rb', line 63

def labels
  headers.map(&:text)
end

#select(item) ⇒ Object

Select method will take a single parameter and click on the h3 element to select it.

Examples:

select('Section 2') will click on the
Section 2 header element and open it.


22
23
24
25
26
27
28
29
# File 'lib/jqueryui_widgets/accordion.rb', line 22

def select(item)
  the_accordions = headers
  index = the_accordions.find_index do |accordion|
    accordion.text == item
  end
  the_accordions[index].click
  wait_for_content(index)
end

#selectedObject

Selected method will check the currently selected accordion element by checking if the class ‘ui-accordin-header-active’ is present within the accordion element.



37
38
39
# File 'lib/jqueryui_widgets/accordion.rb', line 37

def selected
  h3_element(:class => 'ui-accordion-header-active').text
end

#selected?(label) ⇒ Boolean

Selected? compares the passed in label with the current h3_element text and returns a boolean result.

Examples:

selected?('Section 3') will compare the
currently selected header with the 'Section 3'
variable, and return true or false.

Returns:

  • (Boolean)


54
55
56
# File 'lib/jqueryui_widgets/accordion.rb', line 54

def selected?(label)
  selected == label
end