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
Next

For a list of a Web object's internal properties and methods, refer to the Microsoft documentation.

Back to top

Use programmatic descriptions

When UFT One recognizes an object as a Web-based object that does not fit into any other UFT One 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 One clicks the Web object in the Advantage Online Shopping page with the name SIGN IN.

Browser("Advantage Shopping").Page("Advantage Shopping").WebElement("name:=SIGN IN", "type:=button").Click

or

Set WebObjDesc = Description.Create() 
WebObjDesc("name").Value = "SIGN IN" 
WebObjDesc("type").Value = "button" 
Browser("Advantage Shopping").Page("Advantage Shopping").WebElement(WebObjDesc).Click

Back to top