Class: FireWatir::Link

Inherits:
Element show all
Defined in:
lib/firewatir/elements/link.rb

Overview

Description:

Class for Link element.

Constant Summary collapse

TAG =
'A'

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, #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) ⇒ Link

Description:

Initializes the instance of link element.

Input:

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


17
18
19
20
21
# File 'lib/firewatir/elements/link.rb', line 17

def initialize(container, how, what)
  @how = how
  @what = what
  @container = container
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/link.rb', line 7

def element_name
  @element_name
end

Instance Method Details

#locateObject

Description:

Locate the link element on the page.


27
28
29
30
31
32
33
34
35
36
37
# File 'lib/firewatir/elements/link.rb', line 27

def locate
  case @how
  when :jssh_name
    @element_name = @what
  when :xpath
    @element_name = element_by_xpath(@container, @what)
  else
    @element_name = locate_tagged_element('A', @how, @what)
  end
  @o = self
end

#to_sObject

returns a textual description of the link



70
71
72
73
# File 'lib/firewatir/elements/link.rb', line 70

def to_s
  assert_exists
  super({"href" => "href","inner text" => "text"})
end