![]()
API Guide - Button |
Courses in c#, ruby, shell scripting, Software testing courses and more
|
|||||||||||||||||||||||||
|
||||||||||||||||||||||||||
| 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.
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.
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.
Check to see if the object exists or not at runtime.
Returns true if the object exists, false if it doesn’t
Check to see if the object exists or not at runtime.
Returns true if the object exists, false if it doesn’t
| 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. |