Class: Celerity::Button

Inherits:
InputElement show all
Defined in:
lib/celerity/elements/button.rb

Overview

Input: Button

Class representing button elements.

This class covers both <button> and <input type=“submit|reset|image|button” /> elements.

Constant Summary collapse

TAGS =
Identifier.new('button'),
Identifier.new('input', :type => %w[submit reset image button])
ATTRIBUTES =

Attribute list is a little weird due to this class covering both <button> and <input type=“submit|reset|image|button” />

ATTRIBUTES | [
  :accesskey,
  :disabled,
  :ismap,
  :onblur,
  :onfocus,
  :src,
  :tabindex,
  :type,
  :usemap,
]
DEFAULT_HOW =
:value

Constants inherited from Element

Element::BASE_ATTRIBUTES, Element::CELLHALIGN_ATTRIBUTES, Element::CELLVALIGN_ATTRIBUTES, Element::HTML_401_TRANSITIONAL

Instance Attribute Summary

Attributes inherited from Element

#container

Attributes included from Container

#browser

Instance Method Summary collapse

Methods inherited from InputElement

#readonly?

Methods included from DisabledElement

#assert_enabled, #disabled?, #enabled?

Methods included from ClickableElement

#click, #click_and_attach, #double_click, #download, #right_click

Methods inherited from Element

#==, #assert_exists, #attribute_string, #attribute_value, #exists?, #fire_event, #focus, #focused?, #initialize, #javascript_object, #method_missing, #methods, #object, #parent, #respond_to?, #text, #to_s, #to_xml, #visible?, #xpath

Methods included from Container

#area, #areas, #button, #buttons, #cell, #cells, #check_box, #checkboxes, #container=, #contains_text, #dd, #dds, #del, #dels, #div, #divs, #dl, #dls, #dt, #dts, #em, #ems, #file_field, #file_fields, #form, #forms, #frame, #frames, #h1, #h1s, #h2, #h2s, #h3, #h3s, #h4, #h4s, #h5, #h5s, #h6, #h6s, #hidden, #hiddens, #image, #images, #ins, #inses, #inspect, #label, #labels, #li, #link, #links, #lis, #map, #maps, #meta, #metas, #ol, #ols, #option, #p, #pre, #pres, #ps, #radio, #radios, #row, #rows, #select_list, #select_lists, #span, #spans, #strong, #strongs, #table, #tables, #tbodies, #tbody, #text_field, #text_fields, #tfoot, #tfoots, #th, #thead, #theads, #ths, #ul, #uls

Methods included from ShortInspect

#short_inspect

Constructor Details

This class inherits a constructor from Celerity::Element

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Celerity::Element

Instance Method Details

#locateObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/celerity/elements/button.rb', line 34

def locate
  # We want the :value attribute to point to the inner text for <button> elements,
  # and to the value attribute for <input type="button"> elements.
  if (val = @conditions[:value])
    button_ident      = Identifier.new('button')
    button_ident.text = val
    input_ident       = Identifier.new('input', :type => %w[submit reset image button], :value => [val])

    locator        = ElementLocator.new(@container, self.class)
    locator.idents = [button_ident, input_ident]

    conditions = @conditions.dup
    conditions.delete(:value)
    @object = locator.find_by_conditions(conditions)
  else
    super
  end
end