Class: FireWatir::InputElement

Inherits:
Element
  • Object
show all
Defined in:
lib/firewatir/elements/input_element.rb

Overview

Description:

Base class containing items that are common between select list, text field, button, hidden, file field classes.

Direct Known Subclasses

Button, FileField, Option, SelectList, TextField

Constant Summary

Constants inherited from Element

Element::FIRST_ORDERED_NODE_TYPE, Element::NUMBER_TYPE, Element::ORDERED_NODE_ITERATOR_TYPE, Element::TO_S_SIZE

Constants included from Container

Container::DEFAULT_HIGHLIGHT_COLOR, Container::MACHINE_IP

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Element

#assert_enabled, #assert_exists, #attribute_value, #click, #contains_text, #disabled, #document_var, #element_by_xpath, #element_type, #elements_by_xpath, #enabled?, #exists?, #fire_event, #inspect, #method_missing, #text, #to_s, #visible?, #wait

Methods included from Container

#button, #cell, #checkbox, #dd, #dl, #dt, #file_field, #form, #frame, #hidden, #image, #link, #radio, #row, #select_list, #show_all_objects, #table, #text_field

Methods included from JsshSocket

#js_eval, #js_eval_method, #jssh_socket, #read_socket

Constructor Details

#initialize(container, how, what) ⇒ InputElement

Description:

Initializes the instance of element.

Input:

- how - Attribute to identify the element.
- what - Value of that attribute.


35
36
37
38
39
40
41
# File 'lib/firewatir/elements/input_element.rb', line 35

def initialize(container, how, what)
  @how = how
  @what = what
  @container = container
  @element_name = ""
  #super(nil)
end

Dynamic Method Handling

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

Instance Attribute Details

#element_nameObject

Returns the value of attribute element_name.



7
8
9
# File 'lib/firewatir/elements/input_element.rb', line 7

def element_name
  @element_name
end

Instance Method Details

#locateObject

Description:

Locate the element on the page. Element can be a select list, text field, button, hidden, file field.


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/firewatir/elements/input_element.rb', line 12

def locate
  case @how
  when :jssh_name
    @element_name = @what
  when :xpath
    @element_name = element_by_xpath(@container, @what)
  else
    if(self.class::INPUT_TYPES.include?("select-one"))
      @element_name = locate_tagged_element("select", @how, @what, self.class::INPUT_TYPES)
    else
      @element_name = locate_tagged_element("input", @how, @what, self.class::INPUT_TYPES)
    end
  end
  @o = self
end