Open source web testing tool
The future of automated web testing is open source

API Guide - Frame

Courses in c#, ruby, shell scripting, Software testing courses and more

See a video tour
Thwameva technologies offers a state of the art advanced training using multimedia video mentoring , practical oriented training and experts as mentors(*). Thwameva offers software testing courses, courses in WET, ruby, C#, shell scripting and more...
The unique combination of video mentoring by experts and mentor assisted training programs are applicable only for software training courses in Thwameva's Bangalore office.

Thwameva technologies is the primary sponsor for the WET project
 
Main       Web Objects       Win Objects       Test Mgmt       Others      
Class WET::WebFrame
In: WebFrame.rb
Parent: WebCommonFrame

Class to represent a web frame object

   For those web pages that are displayed in a frameset,WET's Frame object can be used to get a reference of the
   Frame.To find out all the frames shown in a Browser,you need to use the Browser's show_frame method.

Methods

Frame   new   show_frames   to_s  

Methods Inherited from WebContainer

Button   Checkbox   File   IFrame   Image   Link   List   Radio   Table   TextField   Textarea   button   checkbox   div   element_by_tagname   file_field   iframe   image   link   p   radio   select_list   span   table   text_field   textarea  

Attributes

container  [R] 

Public Class methods

     Constructor to create a new instance of the frame object.Scripts should not directly invoke the Frame method
     of the Browser class  = Browser.Frame(*args)

     This command is to get the frame with the specified properties.

  1) Getting a reference of the required Frame

     The syntax to get the reference of a Frame is :
     Browser.Frame("name:=value")

   Where

   name    is the name of the attribute to be checked.
   value   is the value of that attribute.

Example

    Browser('title:=Controls').Frame('name:=fr001')

    The commonly used attributes to identify an Image are:

    text    The text of this Frame
    name           The HTML name attribute of the frame
    id      The HTML id attribute of the frame

Actions:

      1) Write the following script in a new ruby file
          #####################################
           require 'WET'
           include WET
           ie = Browser.new()
           ie.goto "http://www.wet.qantom.org/userguide/frameset.html"
           tf = ie.Frame('name:=top')
           puts tf.text
          #####################################

      2) Execute this script

Result:

    The following output should be printed on the console

THIS IS THE TOP FRAME

Public Instance methods

Get a frame with the specified properties.The properties are specified as name-value pairs using the syntax:

"property_name:=value"

The value can either be a string literal or a string representing a regular expression.To emulate a regular expression,the value starts and ends with the ’/’ character.For example: "name:=/some.*/"

The different properties that can be used to identify a frame are:

     name     -   The html name attribute of the frame
     id       -   The html id attribute of the frame
     index    -   The order in which this frame appears on the webpage.

This command is to show the Frames present in the web page.

Methods Inherited from the WebContainer class

Find a Button with the specified properties, The properties are specified as name-value pairs using the syntax:

    "property_name:=value"

The value can either be a string literal or a string representing a regular expression. To emulate a regular expressioin, the value starts and ends with the ’/’ character. For example, "name:=/some.*/"

The common properties used to identify a button are :

  • name - The html name attribute of the button
  • id - The html id attribute of the button
  • value - The value of the button is the text displayed on the button.

Find a Web checkbox with the specified properties. The properties are specified as name-value pairs using the syntax:

    "property_name:=value"

The value can either be a string literal or a string representing a regular expression. To emulate a regular expressioin, the value starts and ends with the ’/’ character. For example, "name:=/some.*/"

The properties used to identify a checkfield are:

  • name - The html name attribute of the checkbox
  • id - The html id attribute of the checkbox
  • label - The checkbox’s label. The checkbox’s label is the text that is
     displayed to the left of the checkbox.
    

Find a Web File with the specified properties. The properties are specified as name-value pairs using the syntax:

    "property_name:=value"

The value can either be a string literal or a string representing a regular expression. To emulate a regular expressioin, the value starts and ends with the ’/’ character. For example, "name:=/some.*/"

The properties used to identify a File are:

  • name - The html name attribute of the file element
  • id - The html name attribute of the file element
  • label - The File element’s label. The label of a file element is the
     text displayed to the left of the file.
    

Find an IFrame with the specified properties. The properties are specified as name-value pairs using the syntax:

    "property_name:=value"

The value can either be a string literal or a string representing a regular expression. To emulate a regular expressioin, the value starts and ends with the ’/’ character. For example, "name:=/some.*/"

The properties used to identify a Textarea are:

  • name - The html name attribute of the text area
  • id - The html id attribute of the text area.
  • text - The text contained in the IFrame

Find an Image with the specified properties. The properties are specified as name-value pairs using the syntax:

    "property_name:=value"

The value can either be a string literal or a string representing a regular expression. To emulate a regular expressioin, the value starts and ends with the ’/’ character. For example, "name:=/some.*/"

The common properties for an image are

  • id - The html id attribute of the image
  • src - The source path

Get a web Link with the specified properties. The properties are specified as name-value pairs using the syntax:

    "property_name:=value"

The value can either be a string literal or a string representing a regular expression. To emulate a regular expressioin, the value starts and ends with the ’/’ character. For example, "name:=/some.*/"

For a link the following are the commonly used properties:

  • id - The html id attribute of the link
  • text - Text that is displayed for the link.
  • href - Url to which this link points to

Find a Web List with the specified properties. The properties are specified as name-value pairs using the syntax:

    "property_name:=value"

The value can either be a string literal or a string representing a regular expression. To emulate a regular expressioin, the value starts and ends with the ’/’ character. For example, "name:=/some.*/"

The properties used to identify a List are:

  • name - The html name attribute of the web list
  • id - The html id attribute of the web list.
  • label - The Lists’s label. A lists label is the text that is
     displayed to the left of the weblist
    

Find a Web radio button with the specified properties. The properties are specified as name-value pairs using the syntax:

    "property_name:=value"

The value can either be a string literal or a string representing a regular expression. To emulate a regular expressioin, the value starts and ends with the ’/’ character. For example, "name:=/some.*/"

The properties used to identify a radio button are:

  • name - The html name attribute of the radio button
  • id - The html id attribute of the radio button
  • label - The radio button’s label. In the case of a radio button, the
     label is considered to be the textimmediately after the radio.
    

Find a HTML Table with the specified properties. The properties are specified as name-value pairs using the syntax:

    "property_name:=value"

The value can either be a string literal or a string representing a regular expression. To emulate a regular expressioin, the value starts and ends with the ’/’ character. For example, "name:=/some.*/"

The properties with which a table can be identified are:

  • id - The html id of the table
  • text - This is a very useful way to identify a table. Sometimes the only
     info that is available about a table is the text contained in the table.
     The table's text is the aggregate of the contents of the cells of the table.
    

Find a Web textfield with the specified properties. The properties are specified as name-value pairs using the syntax:

    "property_name:=value"

The value can either be a string literal or a string representing a regular expression. To emulate a regular expressioin, the value starts and ends with the ’/’ character. For example, "name:=/some.*/"

The properties used to identify a textfield are:

  • name - The html name attribute of the Textfield
  • id - The html id attribute of the Textfield
  • label - The textfield’s label. The textfield’s label is the text
     displayed to the left of the textfield.
    

Find a Textarea with the specified properties. The properties are specified as name-value pairs using the syntax:

    "property_name:=value"

The value can either be a string literal or a string representing a regular expression. To emulate a regular expressioin, the value starts and ends with the ’/’ character. For example, "name:=/some.*/"

The properties used to identify a Textarea are:

  • name - The html name attribute of the text area
  • id - The html id attribute of the text area.
button(*props)

Alias for Button

checkbox(*props)

Alias for Checkbox

Convenience method to access div elements

Get an element based on the tagname. This is useful for those cases where there is no predefined WET class for a particular tag but a scripter needs to use it.

  • tag_name = Name of the tag, eg. p, div, etc.,
  • props = Hashtable of name-value properties for searching.

For example if you want to get a <div> element whose id is ‘myId’, then you can say

    element_by_tag_name("div", "id" => "myId")
file_field(*props)

Alias for File

iframe(*props)

Alias for IFrame

image(*props)

Alias for Image

link(*props)

Alias for Link

Convenience method to access <p> elements

radio(*props)

Alias for Radio

select_list(*props)

Alias for List

Convenience method to access span elements

table(*props)

Alias for Table

text_field(*props)

Alias for TextField

textarea(*props)

Alias for Textarea

Methods inherited from Web Objects

Get the WebBrowser object which hosts this element

Check to see if the object exists or not at runtime.

Returns true if the object exists, false if it doesn’t

Emulate firing an event - For example - moving mouse over, etc,.

Get the ‘id’ attribute that is associated with this element

Get the index of this element w.r.t its container.

is_exist()

Alias for exists?

Get the ‘name’ attribute that is associated with this element

Get the html tag of this element. For example: <input> for textfield, <img> for image, etc.,

 

WET is a opensource automated web testing tool which uses Watir as the library to drive web pages. WET drives an IE Browser directly and so the automated testing done using WET is equivalent to how a user would drive the web pages. WET extends the scripting abilities of Watir and also offers the convenience of recorders. It is licensed under LGPL and BSD style open source licenses.

WWW wet.qantom.org
Search powered by Google