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

API Guide - Button

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

Wrapper sitting on top of Watir’s button

The Button 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 WebButton. Scripts will never have to
 directly instantiate a new WebButton method directly. To create a
 WebButton instance, you'd use the WebContainer.Button(*args)
 method provided by the various containers (Browser, Frame,Table are examples of containers).

 Example:
 Browser("title:=blah").Frame("name:=myName").Button("value:=Ok")

 The syntax to get the reference of a Button is:

 Container.Button("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").Button("text:=New Blank Link")
 The commonly used attributes to identify a Button are:
 name    The HTML name attribute of the button
 id      The HTML id attribute of the button
 value   The text displayed on the button

 Tip:To construct the definition for a button,use the container's show_objects('Button')method.Then pick the one
 that is appropriate for the Button of interest and copy paste it into your script.For example:if you were to say
 Browser('title:=Controls').show_objects('Button')
 then the output is:
 Buttons:-
 Browser('title:=Controls').Button('value:=Alert')
 copy paste the Browser(...)line into your script and you can get a reference of the required Button.

Public Instance methods

Check to see if the button actually exists on the page.If the button actually does exist,then prints out a success message in the test report.If the button 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 whether the button exists on the page.

Check whether the button does not exist on the page.If the button does not exist,then prints out a success message in the test report.If the button 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 ‘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.There are various properties that we can use for a webbutton.The property to be checked is the first parameter and the expected value is the second parameter.The commonly used ones are:

 name     - The html name attribute of the button
 id       - The html id attribute of the button
 value    - The current value of the button
 disabled - To check if the button is enabled or disabled?

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

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

Perform a click on the button.Calling this method is actually left clicking the Web button using the mouse. This action emulates a real user clicking the button.

Perform a click on the button.The click operation is performed in a separately ruby process.This method is uusally used when the browser becomes busy immediately after the button is clicked.When the browser becomes busy,the script cannot proceed to the next line,resulting in a sort of deadlock.A Typical example of browser becoming busy is when it opens a modal dialog box.

Example usage;

  Browser(...).Butoon(...).click_without_blocking
  Browser(...).Dialog(...).Button('value:=OK').click
  Now proceed with the next line of browser processing.

The click_without_blocking() method performs the same click option but in a separate process.This method is used when you are expecting a blocking event (like display of a popup window)to occur.

Gets the value for the button. A button’s value is typically the text displayed on the button.

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.,

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