![]()
API Guide - Image |
Courses in c#, ruby, shell scripting, Software testing courses and more
|
|||||||||||||||||||||||||
|
||||||||||||||||||||||||||
| Class | WET::WebImage |
| In: |
WebImage.rb
|
| Parent: | WebObject |
Wrapper for Watir::Image. Most of the functionality is taken care of by the parent class
The images displayed on a web page are controlled in WET using this object
Create a new instance of a Web Image.This method should not be directly called in the script.Use the WebContainer.Image(*)method.
The images displayed on a web page are controlled in WET using this object
The syntax to get the reference of a image is:
Container.Image("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').Image('base_name:=browser_test.gif')
The commonly used attributes to identify an image are:
id The HTML id attribute of the image
src The source url for this image
basename The 'name'part of the source url
Tip:To construct the definition for an image,use container's show_objects('image')method.Then pick the one that
is appropriate for the image of interest and copy paste it into your script.
The file name of the src for this image. That is, the name of the file
after stripping off the url and paths. Example if the src for the image is:
, then base_name will return
‘image_main.gif‘
Check to see if the image actually exists on the page.If the image actually 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 image *does not*exist on the page.If the image does not exist,then prints out a success 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.
Check if a property’s actual value matches the expected value.The property to be checked is the first parameter and the expected value is the second parameter.The common properties that are checked for image are:
name - The html name attribute of the image.
id - The html id attribute of the image
src - The source location of the image
alt - The 'alt' text that is displayed for the image.
Besides the above properties you could use any of the properties of the MSHtml Image object.The properties are enumerated at; msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/objects/omg.asp
If the result is a success then prints a Success to the report.Otherwise prints a failure.
Perform a click operation on the image.Calling this method is actually left clicking the Web image using the mouse.This command is required to automate the clicking of images.
The click_without_blocking command is the variant of click image which runs in a separate process.Usually called when you expect the click operation to get into a ‘waiting’state.This method is usually used when the browser becomes busy immediately after the image 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 us when it opens a modal dialog box.
Example usage: Browser(…).Image(…).click_without_blocking Browser(…).Dialog(…).Button(‘value:=OK’).click Now proceed with the next line of the browser processing.
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. |