Sha256: b3c2ee33e04930cbcac3acb809999ad3533ce2b49f2847ad2ff6e683a6d6d4da

Contents?: true

Size: 1.15 KB

Versions: 33

Compression:

Stored size: 1.15 KB

Contents

module TestCentricity
  class TextField < UIElement
    def initialize(parent, locator, context)
      @parent  = parent
      @locator = locator
      @context = context
      @type    = :textfield
      @alt_locator = nil
    end

    # Is text field set to read-only?
    #
    # @return [Boolean]
    # @example
    #   comments_field.read_only?
    #
    def read_only?
      obj, _ = find_element
      object_not_found_exception(obj, nil)
      !!obj.native.attribute('readonly')
    end

    # Return maxlength character count of a text field.
    #
    # @return [Integer]
    # @example
    #   max_num_chars = comments_field.get_max_length
    #
    def get_max_length
      obj, _ = find_element
      object_not_found_exception(obj, nil)
      max_length = obj.native.attribute('maxlength')
      max_length.to_i unless max_length.blank?
    end

    # Return placeholder text of a text field.
    #
    # @return [String]
    # @example
    #   placeholder_message = username_field.get_placeholder
    #
    def get_placeholder
      obj, _ = find_element
      object_not_found_exception(obj, nil)
      obj.native.attribute('placeholder')
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
testcentricity_web-0.9.9.1 lib/testcentricity_web/elements/textfield.rb
testcentricity_web-0.9.9 lib/testcentricity_web/elements/textfield.rb
testcentricity_web-0.9.8 lib/testcentricity_web/elements/textfield.rb
testcentricity_web-0.9.7 lib/testcentricity_web/elements/textfield.rb
testcentricity_web-0.9.6.3 lib/testcentricity_web/elements/textfield.rb
testcentricity_web-0.9.6.2 lib/testcentricity_web/elements/textfield.rb
testcentricity_web-0.9.6.1 lib/testcentricity_web/elements/textfield.rb
testcentricity_web-0.9.6 lib/testcentricity_web/elements/textfield.rb
testcentricity_web-0.9.5.1 lib/testcentricity_web/elements/textfield.rb
testcentricity_web-0.9.5 lib/testcentricity_web/elements/textfield.rb
testcentricity_web-0.9.4 lib/testcentricity_web/elements/textfield.rb
testcentricity_web-0.9.3.4 lib/testcentricity_web/elements/textfield.rb
testcentricity_web-0.9.3 lib/testcentricity_web/elements/textfield.rb