Sha256: 8c3bfae8b3da3e90ddadf1c5f6ec820628264d1f914583090bec867bddda5f4c

Contents?: true

Size: 1.95 KB

Versions: 8

Compression:

Stored size: 1.95 KB

Contents

module PageObject
  module Platforms
    module WatirWebDriver
      module SelectList

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

        #
        # Select a value from the list
        #
        def select(value)
          element.select(value)
        end

        #
        # Select the option(s) whose value attribute matches the given
        # string
        #
        def select_value(value)
          element.select_value(value)
        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, :platform => :watir_webdriver) }
        end

        #
        # @return [Array<String>] An array of strings representing the text of the currently selected options.
        #
        def selected_options
          element.selected_options.map { |e| e.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 { |e| e.value }.compact
        end

        #
        # Returns true if the select list has one or more options where text or label matches the given value.
        #
        # @param [String, Regexp] value A value.
        # @return [Boolean]
        def include?(value)
          element.include? value
        end
        
        #
        # Returns true if any of the selected options' text or label match the given value.
        #
        # @param [String, Regexp] value A value.
        # @return [Boolean]
        def selected?(value)
          element.selected? value
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 3 rubygems

Version Path
page-object-1.1.1 lib/page-object/platforms/watir_webdriver/select_list.rb
page_object-1.1.3 lib/page-object/platforms/watir_webdriver/select_list.rb
page_object-1.1.2 lib/page-object/platforms/watir_webdriver/select_list.rb
page_object-1.1.1 lib/page-object/platforms/watir_webdriver/select_list.rb
page-object-1.1.0 lib/page-object/platforms/watir_webdriver/select_list.rb
page-object-1.0.3 lib/page-object/platforms/watir_webdriver/select_list.rb
meeane-page-object-0.1.11 lib/page-object/platforms/watir_webdriver/select_list.rb
page-object-1.0.2 lib/page-object/platforms/watir_webdriver/select_list.rb