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

API Guide - Radio

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::WebRadio
In: WebRadio.rb
Parent: WebObject

# Class to represent a Radio button. Most functionality is implemented in Watir.

   The Radio buttons (select one in a group)controls that are displayed on the web page.

Methods

Methods Inherited from WebObject

browser   exists?   fire_event   id   index   is_exist   name   tag_name  

Public Class methods

Create a new instance of the Web Radio button. Scripts should not create instances of WebRadios directly. Instead they should call the WebContainer.Radio(*args) method provide by containers like Browser, Frame, etc.,

   This is to create a new instance of the Web Radio button.

    The syntax to get the reference of Radio is:
      Container.Radio("name:=value")
    Where
      container is a Browser,Frame,Table or any other container that can hold HTML elements as its children.
      name  is the name of the attribute to be checked
      value is the value of that attribute

    Example

      Browser("title:=Controls").Radio("label:=Radio#5.1")

      The commonly used attributes to identify a radio are:
         name    The HTML name attribute of the radio button
         id      The HTML id attribute of the radio button
         label   The label for this radio button

    Tip:To construct the definition for a radio,use the container's show_object('Radio')method.The pick the one
    that is appropriate for the Radio button of interest and copy paste it into your script.

Public Instance methods

Check to see if the radio button actually exists on the page.If the radio button actually does exist,then prints out a success message in the test report.If it doesn’t exist,then it prints out a failure in the report.One example of using this check is immediately after performing ‘add’ operations.For example,after adding a new user,you may want to check that the user link actually does exist.

Check to see if the radio button *doest not* exist on the page.If the radio button does not exist,then prints out a succes message in the test report.If it actually does exist,then it prints out a failure in the report.One example of using this check is immediately after performing ‘delete’ operations.For example,after deleting user ‘abc’,you may want to check that the user link for ‘abc’ has been deleted.

This method is used to verify that the current value of ‘name’property matches the expected value.The property to be checked is the first parameter and the expected value is the second parameter.There are various properties that you can use for a radio.

The commonly used ones are:

    name      -   The html name attribute of the radio
    id        -   The html id attribute of the radio
    label     -   The label for this radio
    suffix    -   The suffix for a radio is the text tht is immediately after the radio button
    checked   -   Whether or not the checkbox is in the checked state.

Besides the above properties you could use any of the properties of the MSHtml Radio object.The properties are enumerated at: msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/objects/input_radio.asp

If the result is a success then prints a Success to the report.Otherwise prints a failure.

Get the value of the ‘checked’ state of the radio button.Return true if the radio button is checked,false if the radio button is not checked.

Clear is the flip operation of set.In this case,the radio’s state is set to UNCHECKED.

is_checked()

Alias for checked

Set an item in the current radio group.If the argument is invoked without specifying an index then ‘this’ radio button is directly selected.However if an index is specified,then a radio button is selected such that the radio button belongs to the current radio buttons group and with the specified index is selected.

For example,if we have radio1,radio2 and radio3 with the samename,then when you say Radio(‘label=radio2’).set, then the radio2 is directly selected.However if you call Radio("label=radio2).set(3),then the Radio at index 3 will be selected - which is ‘radio3’.

This variant of set command is used to set one of the items in a radio button group.Typically,a radio button is used as a group.There are few options presented to the user,out of which only one is expected to be selected. In such a case,the set(n)method is used which sets the ‘nth’item of the group to be checked.

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