Object Model Reference for GUI Testing > Web > Back Method

Browser Object

Description

A Web browser (or browser tab).

IMPORTANT

The name of the Browser test object is the same as the name of the first Page test object that is learned in that browser or tab.

Although by default, the Browser test object has only the CreationTime property in its description, you can add properties to the description to enhance proper Browser identification. For example, the HasToolbar description properties (True/False) can be used to help filter out popup advertisement browser windows, which do not normally have toolbars, and the OpenedByTestingTool description properties (True/False) can help to identify the specific browser(s) that UFT opened. You can add these description properties to the default browser object definitions in the Object Identification dialog box or to a specific browser object in the Object Properties dialog box or the Object Repository window.

Note: When working with an XBAP application, the Navigate and Learn function does not learn SWF objects in a Browser window. Learning all objects in the Browser window of an XBAP application only learns the Web objects. You can learn WPF objects by starting to the Navigate and Learn function from the WpfWindow object. For details, see the WpfWindow object.

Operations

The sections below list the built-in methods and properties that you can use as operations for the Browser object.

Note: You can also view a list and descriptions of the Browser description properties, for use in object repository descriptions, programmatic descriptions, checkpoint and output value steps, and as argument values for the GetTOProperty and GetROProperty methods.

Methods

Method Back Navigates to the previous page in the browser history list.
Common Method CaptureBitmap Saves a screen capture of the object as a .png or .bmp image using the specified file name.
Common Method Check Checks whether the actual value of an item matches the expected value.
Common Method CheckProperty Checks whether the actual value of the specified object property matches the specified expected value within the specified timeout.
Common Method ChildObjects Returns the collection of child objects contained within the object.
Method ClearCache Clears the browser cache.
Method Close Closes the browser window (or tab) that this test object represents.
Method CloseAllTabs Closes all tabs (if any) and closes the browser window.
Method DeleteCookies Deletes cookies from the browser.
Method DialogExists Checks if a browser dialog box (such as alert, confirmation, or prompt) is currently open.
Method EmbedScript Runs the specified JavaScript each time a page or frame loads or refreshes in the browser.
Method EmbedScriptFromFile Runs the JavaScript stored in the specified file each time a page or frame loads or refreshes in the browser.
Method Forward Navigates to the next page in the browser history list.
Method FullScreen Displays the browser in full-screen mode.
Method GetDialogText Retrieves the text displayed in a browser dialog box such as alert, confirmation, or prompt.
Common Method GetROProperty Returns the current value of the description properties from the object in the application.
Common Method GetTOProperties Returns the collection of properties and values used to identify the object.
Common Method GetTOProperty Returns the value of the specified description properties from the test object description.
Method HandleDialog Clicks a button on the browser dialog box (alert, confirmation, or prompt) after entering a value if necessary.
Method Home Navigates to the home page configured in the browser's settings.
Method IsSiblingTab Indicates whether the specified tab is a sibling of this tab object in the same browser window.
Method Navigate Opens a specified URL in the browser.
Method OpenNewTab Opens a new tab in the browser window.
Common Method Output Retrieves the current value of an item and stores it in a specified location.
Quit Closes all active browser tabs and windows, and kills any browser-related processes.
Method Refresh Refreshes the current page.
Common Method RefreshObject Instructs UFT to re-identify the object in the application the next time a step refers to this object.
Common Method SetTOProperty Sets the value of the specified description properties in the test object description.
Method Sync Waits for the browser to complete the current navigation.
Common Method ToString Returns a string that represents the test object.
Common Method WaitProperty Waits until the specified object property achieves the specified value or exceeds the specified timeout before continuing to the next step.

Properties

Common Property Exist Checks whether the object currently exists in the open application.
Common Property Object Accesses the native methods and properties of the object.

 

Back to top

Back Method

Description

Navigates to the previous page in the browser history list.

Syntax

object.Back

Return Type

None

IMPORTANT

This method is identical to clicking the browser's Back button.

Example


 

Back to top

ClearCache Method

Description

Clears the browser cache.

Syntax

object.ClearCache

Return Type

None

IMPORTANT

This method does not delete the browser's cookies. To do so, use the DeleteCookies method.

Example


 

Back to top

Close Method

Description

Closes the browser window (or tab) that this test object represents.

Syntax

object.Close

Return Type

None

IMPORTANT

Use the CloseAllTabs method to close the currently open tab, all sibling tabs, and the parent browser window.

Example


 

Back to top

CloseAllTabs Method

Description

Closes all tabs (if any) and closes the browser window.

Syntax

object.CloseAllTabs

Return Type

None

IMPORTANT

Example


 

Back to top

DeleteCookies Method

Description

Deletes cookies from the browser.

Syntax

object.DeleteCookies [FromSource]

Arguments

Parameter Description
FromSource Optional. A String value.
The full or partial domain of the source. For example, entering MySite.com or MySite.net clears cookies only from the specified site, and entering MySite clears cookies from all related domains.
Default value = ""

Return Type

None

IMPORTANT

This method does not clear the browser's cache. To do so, use the ClearCache method.

This method is not supported on Safari browsers.

Example


 

Back to top

DialogExists Method

Description

Checks if a browser dialog box (such as alert, confirmation, or prompt) is currently open.

Syntax

object.DialogExists

Return Type

A Boolean value.

IMPORTANT

This method is supported on Google Chrome versions 26 and higher.

Example


 

Back to top

EmbedScript Method

Description

Runs the specified JavaScript each time a page or frame loads or refreshes in the browser.

Syntax

object.EmbedScript Script

Arguments

Parameter Description
Script Required. A String value.
The full content of the JavaScript to embed.

Return Type

None

IMPORTANT

Example


 

Back to top

EmbedScriptFromFile Method

Description

Runs the JavaScript stored in the specified file each time a page or frame loads or refreshes in the browser.

Syntax

object.EmbedScriptFromFile FileName

Arguments

Parameter Description
FileName Required. A String value.

The full path of the JavaScript file to run. The location can be an absolute or relative file system path or an ALM path. 

Return Type

None

IMPORTANT

Example


 

Back to top

Forward Method

Description

Navigates to the next page in the browser history list.

Syntax

object.Forward

Return Type

None

IMPORTANT

This method is identical to clicking the browser's Forward button.

Example


 

Back to top

FullScreen Method

Description

Displays the browser in full-screen mode.

Syntax

object.FullScreen

Return Type

None

IMPORTANT

This method is not recorded on Firefox browsers.

Example


 

Back to top

GetDialogText Method

Description

Retrieves the text displayed in a browser dialog box such as alert, confirmation, or prompt.

Syntax

object.GetDialogText

Return Type

A String value.

IMPORTANT

Example


 

Back to top

HandleDialog Method

Description

Clicks a button on the browser dialog box (alert, confirmation, or prompt) after entering a value if necessary.

Syntax

object.HandleDialog ([button], [Value])

Arguments

Parameter Description
button Optional. A micDialogButton Value.

Default value = 0
Value Optional. A Variant.

Return Type

None.

IMPORTANT

Example


 

Back to top

Home Method

Description

Navigates to the home page configured in the browser's settings.

Syntax

object.Home

Return Type

None

IMPORTANT

Example


 

Back to top

IsSiblingTab Method

Description

Indicates whether the specified tab is a sibling of this tab object in the same browser window.

Syntax

object.IsSiblingTab (BrowserObject)

Arguments

Parameter Description
BrowserObject Required. An Object.
The browser test object representing a different tab in the same browser window.

Return Type

A Boolean value.

Example


 

Back to top

Navigate Method

Description

Opens a specified URL in the browser.

Syntax

object.Navigate Location, [TargetFrame], [PostData], [Headers]

Arguments

Parameter Description
Location Required. A String value.
The URL to open in the browser.
TargetFrame Optional. A String value.
The frame to which the URL will be sent.
Note: The frame name is specified in the NAME argument of the <FRAME> tag in the HTML source.


Default value = "_top"

PostData Optional. A String value.
The data that accompanies a Post request.
Default value = ""
Headers Optional. A String value.
Any header data, such as cookies and content-type.
Default value = ""

Return Type

None

Example


 

Back to top

OpenNewTab Method

Description

Opens a new tab in the browser window.

Syntax

object.OpenNewTab

Return Type

None

Example


Back to top

Quit Method

Closes all active browser tabs and windows, and kills any browser-related processes.

Syntax

object.Quit

Return Type

None


 

Back to top

Refresh Method

Description

Refreshes the current page.

Syntax

object.Refresh

Return Type

None

IMPORTANT

This method is identical to clicking the browser's Refresh button.

Example


 

Back to top

Sync Method

Description

Waits for the browser to complete the current navigation.

Syntax

object.Sync

Return Type

None

IMPORTANT

You can use this method to instruct your test to wait until the browser is loaded.

For Mozilla FireFox, this method is recorded as a Page.Sync method.

Example


Back to top

See also: