Sha256: 9a91a05925f256de42552319638cd51353d32555edd2d7e5690d633e044b0800

Contents?: true

Size: 1.05 KB

Versions: 6

Compression:

Stored size: 1.05 KB

Contents

module PageObject
  module Elements
    class SelectList < Element

      #
      # Return the PageObject::Elements::Option for the index provided.  Index
      # is zero based.
      #
      # @return [PageObject::Elements::Option]
      #
      def [](idx)
        options[idx]
      end

      #
      # Return an array of Options contained in the select list.
      #
      # @return [array of PageObject::Elements::Option]
      #
      def options
        element.options.map { |e| PageObject::Elements::Option.new(e) }
      end

      #
      # @return [Array<String>] An array of strings representing the text of the currently selected options.
      #
      def selected_options
        element.selected_options.map(&:text).compact
      end

      #
      # @return [Array<String>] An array of strings representing the value of the currently selected options.
      #
      def selected_values
        element.selected_options.map(&:value).compact
      end

    end

    ::PageObject::Elements.tag_to_class[:select] = ::PageObject::Elements::SelectList
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
page-object-2.2.6 lib/page-object/elements/select_list.rb
page-object-2.2.5 lib/page-object/elements/select_list.rb
page-object-2.2.4 lib/page-object/elements/select_list.rb
page-object-2.2.3 lib/page-object/elements/select_list.rb
page-object-2.2.2 lib/page-object/elements/select_list.rb
page-object-2.2.1 lib/page-object/elements/select_list.rb