Class: Watir::Container::HtmlElement

Inherits:
Object
  • Object
show all
Defined in:
lib/safariwatir.rb

Direct Known Subclasses

ContentElement, Form, Image, InputElement

Constant Summary collapse

OPERATIONS =
{
  :id => "by_id",
  :index => "by_index",
  :class => "by_class",
  :name => "by_name",
  :text => { "Link" => "on_link", "Label" => "by_text" },
  :url => "on_link",
  :value => "by_input_value",
  :caption => "by_input_value",
  :src => "by_src",
  :xpath => "by_xpath",
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#howObject (readonly)

Returns the value of attribute how.



101
102
103
# File 'lib/safariwatir.rb', line 101

def how
  @how
end

#whatObject (readonly)

Returns the value of attribute what.



101
102
103
# File 'lib/safariwatir.rb', line 101

def what
  @what
end

Instance Method Details

#exists?Boolean Also known as: exist?

Returns:

  • (Boolean)


113
114
115
# File 'lib/safariwatir.rb', line 113

def exists?
  @scripter.element_exists?(self)
end

#nameObject



118
119
120
# File 'lib/safariwatir.rb', line 118

def name
  self.class.name.split("::").last
end

#operate(&block) ⇒ Object



122
123
124
125
126
127
128
129
130
131
# File 'lib/safariwatir.rb', line 122

def operate(&block)
  scripter_suffix = OPERATIONS[how]
  if scripter_suffix.kind_of? Hash
    scripter_suffix = scripter_suffix[name]
  end
  if scripter_suffix.nil?
    raise "SafariWatir does not currently support finding by #{how}"
  end
  @scripter.send("operate_#{scripter_suffix}", self, &block)        
end

#speakObject

overridden in derivitives



109
110
111
# File 'lib/safariwatir.rb', line 109

def speak
  @scripter.speak("#{name}'s don't know how to speak.")
end

#tagObject

overridden in derivitives

Raises:

  • (RuntimeError)


104
105
106
# File 'lib/safariwatir.rb', line 104

def tag
  raise RuntimeError, "tag not provided for #{name}"
end