module FireWatir::Container

Constants

DEFAULT_HIGHLIGHT_COLOR

The default color for highlighting objects as they are accessed.

MACHINE_IP

IP Address of the machine where the script is to be executed. Default to localhost.

Public Instance Methods

button(how, what=nil) click to toggle source

Description:

Used to access a button element. Usually an <input type = "button"> HTML tag.

Input:

- how - The attribute used to identify the row.
- what - The value of that attribute.

Typical Usage:

ff.button(:id,    'b_1')                       # access the button with an ID of b_1
ff.button(:name,  'verify_data')               # access the button with a name of verify_data

if only a single parameter is supplied,  then :value is used as 'how' and parameter supplied is used as what. 

ff.button('Click Me')                          # access the button with a value of Click Me

Output:

Button element.
# File lib/firewatir/container.rb, line 191
def button(how, what=nil)
  locate if respond_to?(:locate)
  if what.nil? && String === how
    what = how
    how = :value
  end    
  Button.new(self, how, what)
end
cell(how, what=nil) click to toggle source

Description:

Used to access a table cell. Usually an <td> HTML tag.

Input:

- how - The attribute used to identify the cell.
- what - The value of that attribute.

Typical Usage:

ff.cell(:id, 'tb_cell')
ff.cell(:index, 1)

Output:

TableCell Object
# File lib/firewatir/container.rb, line 147
def cell(how, what=nil)
  locate if respond_to?(:locate)
  TableCell.new(self, how, what)
end
checkbox(how, what=nil, value = nil) click to toggle source

Description:

Used to access checkbox element. Usually an <input type = checkbox> HTML tag.

Input:

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

Typical Usage:

ff.checkbox(:id,   'user_name')                 # access the checkbox element with an ID of user_name
ff.checkbox(:name, 'address')                   # access the checkbox element with a name of address
In many instances, checkboxes on an html page have the same name, but are identified by different values. An example is shown next.

<input type = checkbox name = email_frequency value = 'daily' > Daily Email
<input type = checkbox name = email_frequency value = 'Weekly'> Weekly Email
<input type = checkbox name = email_frequency value = 'monthly'>Monthly Email

FireWatir can access these using the following:

ff.checkbox(:id, 'day_to_send' , 'monday' )         # access the check box with an id of day_to_send and a value of monday
ff.checkbox(:name ,'email_frequency', 'weekly')     # access the check box with a name of email_frequency and a value of 'weekly'

Output:

Checkbox object.
# File lib/firewatir/container.rb, line 309
def checkbox(how, what=nil, value = nil) 
  locate if respond_to?(:locate)
  return CheckBox.new(self, how, what, value) 
end
dd(how, what = nil) click to toggle source

Description:

Used to access a definition description element - a <dd> HTML tag.

Input:

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

Typical Usage:

ff.dd(:id, 'user_name')                    # access the dd element with an ID of user_name
ff.dd(:title, 'address')                   # access the dd element with a title of address

Returns:

Dd object.
# File lib/firewatir/container.rb, line 446
def dd(how, what = nil)
  locate if respond_to?(:locate)
  Dd.new(self, how, what)
end
dl(how, what = nil) click to toggle source

Description:

Used to access a definition list element - a <dl> HTML tag.

Input:

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

Typical Usage:

ff.dl(:id, 'user_name')                    # access the dl element with an ID of user_name
ff.dl(:title, 'address')                   # access the dl element with a title of address

Returns:

Dl object.
# File lib/firewatir/container.rb, line 404
def dl(how, what = nil)
  locate if respond_to?(:locate)
  Dl.new(self, how, what)
end
dt(how, what = nil) click to toggle source

Description:

Used to access a definition term element - a <dt> HTML tag.

Input:

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

Typical Usage:

ff.dt(:id, 'user_name')                    # access the dt element with an ID of user_name
ff.dt(:title, 'address')                   # access the dt element with a title of address

Returns:

Dt object.
# File lib/firewatir/container.rb, line 425
def dt(how, what = nil)
  locate if respond_to?(:locate)
  Dt.new(self, how, what)
end
file_field(how, what = nil) click to toggle source

Description:

Used for accessing a file field. Usually an <input type = file> HTML tag.

Input:

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

Typical Usage:

ff.file_field(:id,   'up_1')                     # access the file upload fff.d with an ID of up_1
ff.file_field(:name, 'upload')                   # access the file upload fff.d with a name of upload

Output:

FileField object
# File lib/firewatir/container.rb, line 215
def file_field(how, what = nil)
  locate if respond_to?(:locate)
  FileField.new(self, how, what)
end
form(how, what=nil) click to toggle source

Description:

Used to access a form element. Usually an <form> HTML tag.

Input:

- how - The attribute used to identify the form.
- what - The value of that attribute. 
If only one parameter is supplied, "how" is by default taken as name and the 
parameter supplied becomes the value of the name attribute.

Typical usage:

ff.form(:index, 1) 
ff.form(:name , 'main_form')
ff.form('main_form')        # in this case, just a name is supplied.

Output:

Form object.
# File lib/firewatir/container.rb, line 102
def form(how, what=nil)   
  locate if respond_to?(:locate)
  if(what == nil)
    what = how
    how = :name
  end    
  Form.new(self, how, what)
end
frame(how, what = nil) click to toggle source

Description:

Used to access a frame element. Usually an <frame> or <iframe> HTML tag.

Input:

- how - The attribute used to identify the framet.
- what - The value of that attribute. 
If only one parameter is supplied, "how" is by default taken as name and the 
parameter supplied becomes the value of the name attribute.

Typical usage:

ff.frame(:index, 1) 
ff.frame(:name , 'main_frame')
ff.frame('main_frame')        # in this case, just a name is supplied.

Output:

Frame object.
# File lib/firewatir/container.rb, line 74
def frame(how, what = nil)
  locate if respond_to?(:locate)
  if(what == nil)
    what = how
    how = :name
  end
  Frame.new(self, how, what)
end
hidden(how, what=nil) click to toggle source

Description:

Used to access hidden field element. Usually an <input type = hidden> HTML tag

Input:

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

Typical Usage:

ff.hidden(:id,   'user_name')                 # access the hidden element with an ID of user_name
ff.hidden(:name, 'address')                   # access the hidden element with a name of address

Output:

Hidden object.
# File lib/firewatir/container.rb, line 257
def hidden(how, what=nil)
  locate if respond_to?(:locate)
  return Hidden.new(self, how, what)
end
image(how, what = nil) click to toggle source

Description:

Used to access image element. Usually an <img> HTML tag.

Input:

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

Typical Usage:

ff.image(:id,   'user_name')                 # access the image element with an ID of user_name
ff.image(:name, 'address')                   # access the image element with a name of address

Output:

Image object.
# File lib/firewatir/container.rb, line 382
def image(how, what = nil)
  locate if respond_to?(:locate)
  Image.new(self, how, what)
end
radio(how, what=nil, value = nil) click to toggle source

Description:

Used to access radio button element. Usually an <input type = radio> HTML tag.

Input:

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

Typical Usage:

ff.radio(:id,   'user_name')                 # access the radio button element with an ID of user_name
ff.radio(:name, 'address')                   # access the radio button element with a name of address
In many instances, radio buttons on an html page have the same name, but are identified by different values. An example is shown next.

<input type = radio name = email_frequency value = 'daily' > Daily Email
<input type = radio name = email_frequency value = 'Weekly'> Weekly Email
<input type = radio name = email_frequency value = 'monthly'>Monthly Email

FireWatir can access these using the following:

ff.radio(:id, 'day_to_send' , 'monday' )         # access the radio button with an id of day_to_send and a value of monday
ff.radio(:name ,'email_frequency', 'weekly')     # access the radio button with a name of email_frequency and a value of 'weekly'

Output:

Radio button object.
# File lib/firewatir/container.rb, line 340
def radio(how, what=nil, value = nil) 
  locate if respond_to?(:locate)
  return Radio.new(self, how, what, value) 
end
row(how, what=nil) click to toggle source

Description:

Used to access a table row. Usually an <tr> HTML tag.

Input:

- how - The attribute used to identify the row.
- what - The value of that attribute.

Typical Usage:

ff.row(:id, 'tb_row')
ff.row(:index, 1)

Output:

TableRow object
# File lib/firewatir/container.rb, line 167
def row(how, what=nil)
  locate if respond_to?(:locate)
  TableRow.new(self, how, what)
end
select_list(how, what=nil) click to toggle source

Description:

Used to access select list element. Usually an <select> HTML tag.

Input:

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

Typical Usage:

ff.select_list(:id,   'user_name')                 # access the select list with an ID of user_name
ff.select_list(:name, 'address')                   # access the select list with a name of address

Output:

Select List object.
# File lib/firewatir/container.rb, line 278
def select_list(how, what=nil) 
  locate if respond_to?(:locate)
  return SelectList.new(self, how, what)
end
show_all_objects(output = true) click to toggle source

Description:

This method shows the available objects on the current page.
This is usually only used for debugging or writing new test scripts.
This is a nice feature to help find out what HTML objects are on a page
when developing a test case using FireWatir.

Typical Usage:

ff.show_all_objects

Output:

Prints all the available elements on the page.
# File lib/firewatir/container.rb, line 473
def show_all_objects(output = true)
  locate if respond_to?(:locate)
  elements = Document.new(self).all
  if output
    puts "-----------Objects in the current context-------------"
    puts elements.length
    elements.each  do |n|
      puts n.tagName
      puts n.to_s
      puts "------------------------------------------"
    end
    puts "Total number of objects in the current context :  #{elements.length}"
  end
  return elements
  # Test the index access. 

  # puts doc[35].to_s

end
table(how, what=nil) click to toggle source

Description:

Used to access a table. Usually an <table> HTML tag.

Input:

- how - The attribute used to identify the table.
- what - The value of that attribute.

Typical usage:

ff.table(:index, 1) #index starts from 1.
ff.table(:id, 'main_table')

Output:

Table object.
# File lib/firewatir/container.rb, line 127
def table(how, what=nil)
  locate if respond_to?(:locate)
  Table.new(self, how, what)
end
text_field(how, what = nil) click to toggle source

Description:

Used for accessing a text field. Usually an <input type = text> HTML tag. or a text area - a  <textarea> tag

Input:

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

Typical Usage:

ff.text_field(:id,   'user_name')                 # access the text field with an ID of user_name
ff.text_field(:name, 'address')                   # access the text field with a name of address

Output:

TextField object.
# File lib/firewatir/container.rb, line 236
def text_field(how, what = nil)
  locate if respond_to?(:locate)
  TextField.new(self, how, what)
end