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 OpenText Functional Testing 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 BackNavigates to the previous page in the browser history list.
Common Method CaptureBitmapSaves a screen capture of the object as a .png or .bmp image using the specified file name.
Common Method CheckChecks whether the actual value of an item matches the expected value.
Common Method CheckPropertyChecks whether the actual value of the specified object property matches the specified expected value within the specified timeout.
Common Method ChildObjectsReturns the collection of child objects contained within the object.
Common Method GetAllROProperties

Returns the collection of properties and current values from the object in the application.

Method ClearCacheClears the browser cache.
Method CloseCloses the browser window (or tab) that this test object represents.
Method CloseAllTabsCloses all tabs (if any) and closes the browser window.
Method DeleteCookiesDeletes cookies from the browser.
Method DialogExistsChecks if a browser dialog box (such as alert, confirmation, or prompt) is currently open.
Method EmbedScriptRuns the specified JavaScript each time a page or frame loads or refreshes in the browser.
Method EmbedScriptFromFileRuns the JavaScript stored in the specified file each time a page or frame loads or refreshes in the browser.
Method ForwardNavigates to the next page in the browser history list.
Method FullScreenSets the browser's full-screen mode off or on or toggles it.
Method GetDialogTextRetrieves the text displayed in a browser dialog box such as alert, confirmation, or prompt.
Common Method GetROPropertyReturns the current value of the description property from the object in the application.
Common Method GetTOPropertiesReturns the collection of properties and values used to identify the object.
Common Method GetTOPropertyReturns the value of the specified description property from the test object description.
Common Method HighlightHighlights the object in the application.
Method HandleDialogClicks a button on the browser dialog box (alert, confirmation, or prompt) after entering a value if necessary.
Method HomeNavigates to the home page configured in the browser's settings.
Method IsSiblingTabIndicates whether the specified tab is a sibling of this tab object in the same browser window.

Method Maximize

Maximizes the browser window.
Method MinimizeMinimizes the browser window to an icon.
Method NavigateOpens a specified URL in the browser.
Method OpenNewTabOpens a new tab in the browser window.
Common Method OutputRetrieves the current value of an item and stores it in a specified location.
QuitCloses all active browser tabs and windows, and kills any browser-related processes.
Method RefreshRefreshes the current page.
Common Method RefreshObjectInstructs OpenText Functional Testing to re-identify the object in the application the next time a step refers to this object.
Method RestoreRestores the browser window to its previous size.
Common Method SetTOPropertySets the value of the specified description property in the test object description.
Method SyncWaits for the browser to complete the current navigation.
Common Method ToStringReturns a string that represents the test object.
Common Method WaitPropertyWaits until the specified object property achieves the specified value or exceeds the specified timeout before continuing to the next step.

Properties

Common Property ExistChecks whether the object currently exists in the open application.
Common Property ObjectAccesses 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

  • This method closes all of the following:
    • the tab that is currently open
    • all sibling tabs in the parent browser window
    • the parent browser window
  • Use the Close method to close only the tab (and the browser if the browser contains one or no tabs).

  • This method is not recorded on Chrome browsers.

Example

Back to top

 

DeleteCookies Method

Description

Deletes cookies from the browser.

Syntax

object.DeleteCookies [FromSource]

Arguments

ParameterDescription
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

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

Return Type

None

IMPORTANT

  • The script remains embedded until you close the browser, or until the run session ends.
  • Using this method to perform alert operations may result in unexpected behavior.
  • The entire script must be specified as the argument value (as a string or variable). To embed a JavaScript file, use the EmbedScriptFromFile method.
  • To run this method, the security settings in your Web browser must be set to allow active scripting. Otherwise, steps using this method will fail.

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

ParameterDescription
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

  • The JavaScript file remains embedded in the Web page until you close the browser, or until the run session ends.
  • Using this method to perform alert operations may result in unexpected behavior.
  • The function that embeds the JavaScript file may be called more than once. Make sure that this does not result in unwanted functionality. For example, if relevant, you may want to design the JavaScript file itself so that it will only be loaded if it is not already included in the Web page.
  • This method embeds a JavaScript from a specified file. To embed a script directly as the argument value, use the EmbedScript method.
  • To run this method, the security settings in your Web browser must be set to allow active scripting. Otherwise, steps using this method will fail. 

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

Sets the browser's full-screen mode off or on or toggles it.

Syntax

object.FullScreen mode

Arguments

ParameterDescription
mode Optional. A String value.

Specifies whether to toggle the browser's full-screen mode or to set the full-screen mode on or off.

Possible values: 

FULL_SCREEN_ON. Turn on full-screen mode.

FULL_SCREEN_OFF. Exit full-screen mode.

FULL_SCREEN_TOGGLE (Default). Toggle the full-screen mode.

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

  • This method is used in Mozilla Firefox versions 4 and higher to replace the use of the Dialog("").Page("").<Web element> syntax in your test or component. Any existing tests and components last modified in Firefox versions earlier than 4 may need to be updated to run steps on Firefox versions 4 and higher.
  • This method is supported on Google Chrome versions 26 and higher.

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

ParameterDescription
button Optional. A micDialogButton Value.

Default value = 0
Value Optional. A Variant.

Return Type

None.

IMPORTANT

  • This method is used in Mozilla Firefox versions 4 and higher to replace the use of the Dialog("").Page("").<Web element> syntax in your test or component. Any existing tests and components last modified in Firefox versions earlier than 4 may need to be updated to run steps on Firefox versions 4 and higher.
  • This method is supported on Google Chrome versions 26 and higher.

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

  • This method is identical to clicking the browser's Home button.
  • This method is not supported for recording on Mozilla Firefox or Google Chrome.
  • This method is not supported on Google Chrome.

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

ParameterDescription
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

 

Maximize Method

Maximizes the browser window.

Syntax

object.Maximize

Return Type

None

IMPORTANT

This method is not recorded.

Back to top

 

Minimize Method

Minimizes the browser window to an icon.

Syntax

object.Minimize

Return Type

None

IMPORTANT

This method is not recorded.

Back to top

 

Navigate Method

Description

Opens a specified URL in the browser.

Syntax

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

Arguments

ParameterDescription
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

IMPORTANT

  • Use the default value of the Headers parameter if you use the latest UFT Agent Chrome extension (MV3).

  • The TargetFrame and PostData parameters are supported on Internet Explorer only.

Example

Back to top

 

OpenNewTab Method

Description

Opens a new tab in the browser window.

Syntax

object.OpenNewTab

Return Type

None

IMPORTANT

On Safari, the new tab navigates to the URL for new tab, defined in the Safari extension's preferences. For details, see the OpenText Functional Testing Help Center.

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

 

Restore Method

Restores the browser window to its previous size.

Syntax

object.Restore

Return Type

None

IMPORTANT

This method is not recorded.

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: