Class: Vapir::IE::TextField

Inherits:
InputElement show all
Includes:
TextField
Defined in:
lib/vapir-ie/input_elements.rb

Overview

This class is the main class for Text Fields Normally a user would not need to create this object as it is returned by the Vapir::Container#text_field method

Direct Known Subclasses

Hidden

Instance Method Summary collapse

Methods inherited from Element

#after?, #assert_enabled, #before?, #click, #click_no_wait, element_object_style, #enabled?, #fire_event, #fire_event_no_wait, #scroll_offset, #text_after_begin, #text_after_end, #text_before_begin, #text_before_end, #wait

Methods included from Container

#handling_existence_failure, #log

Instance Method Details

#drag_contents_to(destination_how, destination_what) ⇒ Object

Drag the entire contents of the text field to another text field

19 Jan 2005 - It is added as prototype functionality, and may change
 * destination_how   - symbol, :id, :name how we identify the drop target
 * destination_what  - string or regular expression, the name, id, etc of the text field that will be the drop target


65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/vapir-ie/input_elements.rb', line 65

def drag_contents_to(destination_how, destination_what)
  assert_exists do
    destination = @container.text_field!(destination_how, destination_what)
    
    element_object.focus
    element_object.select
    value = self.value
    
    with_highlight do
      fire_event("onSelect")
      fire_event("ondragstart")
      fire_event("ondrag")
      destination.with_highlight do
        destination.fire_event("onDragEnter")
        destination.fire_event("onDragOver")
        destination.fire_event("ondrop")
        destination.value = destination.value + value.to_s
      end
      fire_event("ondragend")
      self.value = ""
    end
    
  end
end

#verify_contains(target) ⇒ Object

Returns true if the text field contents is matches the specified target, which can be either a string or a regular expression.

Raises UnknownObjectException if the object can't be found

TODO: move to common



50
51
52
53
54
55
56
57
58
59
# File 'lib/vapir-ie/input_elements.rb', line 50

def verify_contains(target) # FIXME: verify_contains should have same name and semantics as IE#contains_text (prolly make this work for all elements)
  assert_exists do
    if target.kind_of? String
      return true if self.value == target
    elsif target.kind_of? Regexp
      return true if self.value.match(target) != nil
    end
    return false
  end
end