Advanced operations

When you work with Web applications and Web pages, use the following operations to perform deeper testing.

Use the .Object property

In the Editor, you can use the Object property to activate the method for a Web object. Activating the method for a Web object has the following syntax:

WebObjectName.Object.Method_to_activate( )

For example, suppose you have the following statement in your script:

document.MyForm.MyHiddenField.value = "My New Text"

The following example achieves the same thing by using the Object property, where MyDoc is the DOM's document:

Dim MyDoc
Set MyDoc = Browser(browser_name).page(page_name).Object
MyDoc.MyForm.MyHiddenField.value = "My New Text"

In the following example, LinksCollecton is assigned to the link collection of the page through the Object property. Then, a message box opens for each of the links, with its innerHTML text.

Dim LinksCollection, link
Set LinksCollection = Browser(browser_name).Page(page_name).Object.links
For Each link in LinksCollection
	MsgBox link.innerHTML

For a list of a Web object's internal properties and methods, see:

Back to top

Use programmatic descriptions

When UFT recognizes an object as a Web-based object that does not fit into any other UFT test object class, it learns the object as a WebElement object. You can also use a programmatic description with a WebElement test object to perform methods on any Web object in your Web site.

For example, when you run either of the examples below, UFT clicks the first Web object in the Mercury Tours page with the name UserName.

Browser("Mercury Tours").Page("Mercury Tours").WebElement("Name:=UserName", "Index:=0").Click


set WebObjDesc = Description.Create() 
WebObjDesc("Name").Value = "UserName" 
WebObjDesc("Index").Value = "0" 
Browser("Mercury Tours").Page("Mercury Tours").WebElement(WebObjDesc).Click

Back to top