WebUtil Object

UFT One version 2023 and later: Digital Lab is known as UFT Mobile.

Description

Enables you to set or modify Web related settings.

Associated Methods

Method AddCookieAdds a cookie to the test transaction file.
AttachRemoteDebugging

Enables UFT One to access an application containing Chromium-based Frameworks or Microsoft Edge WebView2 controls through a specific address and port during a run session.

Method DeleteCookieDeletes a cookie from the cookie table.
DeleteCookiesDeletes all cookies for the browser being used in the test run.
DetachRemoteDebuggingStops the connection to an application containing Chromium Embedded Frame and Electron controls or Microsoft Edge WebView2 controls during a run session.
GetCookiesRetrieves the list of cookies for the browser being used in the testtransaction file run.
LaunchBrowserLaunches a browser based on the specific parameters.
LaunchMobileBrowserWithID

Launches a mobile browser on a device using the Digital Lab (UFT Mobile)'s device ID.

Back to top

AddCookie Method

Description

Adds a cookie to the test transaction file.

IMPORTANT

This method is supported for Internet Explorer browsers only.

Syntax

WebUtil.AddCookiedomain, cookies

Argument

Type

Description

domain

String

The name of the domain that the host uses.

cookies

String

The cookie information in the format:

NAME=VALUE; expires=DATE;path=PATH; domain=DOMAIN_NAME; secure.

Back to top

AttachRemoteDebugging Method

Description

Enables UFT One to access an application containing Chromium-based frameworks or Microsoft Edge WebView2 controls through a specific address and port during a run session.

Syntax

WebUtil.AttachRemoteDebugging URL:port, [Mode], [WebDriverPath]

Argument

Type

Description

URL:port

String

The address of the application and the port number used to access it.

The port number is the Chrome remote debugging port number configured in your application.

ModeString

Optional. Specifies whether to use the NW.js ChromeDriver or UFT One's default ChromeDriver, which is relevant for CEF, Electron, or JxBrowser framework objects.

Possible values:

  • nw.js - Use the NW.js ChromeDriver.
  • default - Use the default ChromeDriver. (This is the default value for this parameter)
  • MsEdgeWebView2 - Use the WebView2 driver.

WebDriverPathString

Optional. The path to a specific ChromeDriver to use when testing the specified application.

When provided, UFT One uses this driver instead of the default drivers normally associated with the specified Mode.

Back to top

DeleteCookie Method

Description

Deletes a cookie from the cookie table.

IMPORTANT

This method is supported for Internet Explorer browsers only.

Syntax

WebUtil.DeleteCookiedomain, cookies

Argument

Type

Description

domain

String

Name of the domain that the host uses.

cookies

String

The cookie information in the format:

NAME=VALUE; expires=DATE;path=PATH; domain=DOMAIN_NAME; secure.

Back to top

DeleteCookies Method

Description

Deletes all cookies for the browser being used in the test run.

IMPORTANT

This method is supported for Internet Explorer browsers only.

Syntax

WebUtil.DeleteCookies

Back to top

DetachRemoteDebugging Method

Description

Stops the connection to an application containing Chromium-based framework controls or Microsoft Edge WebView2 controls during a run session.

Syntax

WebUtil.DetachRemoteDebugging URL:port

Argument

Type

Description

URL:port

String

The address of the application and the port number used to access it.

The port number is the Chrome remote debugging port number configured in your application.

Back to top

GetCookies Method

Description

Retrieves the list of cookies for the browser being used in the test transaction file run.

IMPORTANT

This method is supported for Internet Explorer browsers only.

Syntax

WebUtil.GetCookieURL

Argument

Type

Description

URL

String

The URL of the site from which to return the cookies.

This URL must contain http:// to return the cookies for the selected site.

Return Value

A list of all cookies for the site

Back to top

LaunchBrowser Method

Description

Launches a browser based on the specific parameters.

IMPORTANT

Use this method to set a device only before any additional browser steps. Using this method after already having set a device may produce unexpected results.

For example, use this method as follows:

WebUtil.LaunchBrowser "MOBILE_CHROME", "lT-1", "cube", "ANDROID", "5.1"
Browser("Nested Lists").Page("Page").WebEdit("Name").Set "Mercury"
Browser("Nested Lists").Page("Page").WebEdit("Name").CheckProperty "value", "Mercury"

Workaround: To switch devices in the middle of your test, use the Browser Object methods. For example:

Device("Device").App("identifier:==MC.Browser","instrumented:=false").Launch DoNotInstall, Restart
Browser("Device1").Page("Page").WebEdit("Name").Set "Mercury"
Browser("Device2").Page("Page").WebEdit("Name").Set "Mercury"

Syntax

WebUtil.LaunchBrowserBrowser, [device_model, device_manufacturer, device_ostype, device_osversion, device_source]

Argument

Type

Description

Browser

String

Required. The name of the browser to launch.

Possible values:

  • CHROME
  • CHROME_EMULATOR
  • CHROME_HEADLESS

  • CHROMIUMEDGE
  • EDGE
  • FF<VersionNumber>
  • FIREFOX
  • FIREFOX64
  • IE

  • IE64
  • MOBILE_CHROME

  • MOBILE_HPWEB
  • MOBILE_SAFARI

  • PHANTOMJS
  • SAFARI
device_modelString

Optional. The model of the selected device containing the browser.

This parameter should not be used when launching browsers on a desktop.

Device names must be identical to those listed in the Device section in the Digital Lab (UFT Mobile) Wizard.

device_manufacturerString

Optional. The manufacturer of the specific device.

This parameter should not be used when launching browsers on a desktop.

device_ostypeString

Optional. The operating system running on the specified device.

This parameter should not be used when launching browsers on a desktop.

One of the following:

  • ANDROID
  • IOS

Mandatory if the Browser value is set to MOBILE_CHROME, MOBILE_SAFARI, or MOBILE_HPEWEB.

device_osversionString

Optional. The operating system version running on the specified device.

This parameter should not be used when launching browsers on a desktop.

device_sourceString

Supported when using UFT Mobile 3.4 and later.

Optional. The source of the device containing the browser.

This parameter should not be used when launching browsers on a desktop.

Possible values:
  • Any. The device is stored or provided by any of the supported sources.

  • UFTM. The device is stored on Digital Lab (UFT Mobile). (Default)

    Note: The value MC is supported as well, for backward compatibility.

  • AWS. The device is provided by an AWS device farm.

  • HOSTED. The device is hosted by Micro Focus.

UFT Mobile version 2022 or later: 

  • WETEST. The device is provided by a Tencent WeTest device farm.

  • GENYCLOUD. The device is provided by Genymotion.

Return Value

None

Back to top

LaunchMobileBrowserWithID Method

Description

Launches a mobile browser on a device using the Digital Lab (UFT Mobile)'s device ID.

IMPORTANT

Use this method to set a device only before any additional browser steps. Using this method after already having set a device may produce unexpected results.

For example, use this method as follows:

WebUtil.LaunchMobileBrowserWithID "MOBILE_CHROME", "ANDROID", "03"
Browser("Nested Lists").Page("Page").WebEdit("Name").Set "Mercury"
Browser("Nested Lists").Page("Page").WebEdit("Name").CheckProperty "value", "Mercury

Workaround: To switch devices in the middle of your test, use the Device Object methods. For example:

Browser("Device1").Page("Page").WebEdit("Name").Set "Mercury"
Browser("Device2").Page("Page").WebEdit("Name").Set "Mercury"

Syntax

WebUtil.LaunchMobileBrowserWithIDBrowser, device_ostype, device_id

Argument

Type

Description

Browser

String

Required. The name of the browser to launch.

Possible values:

  • MOBILE_HPWEB

  • MOBILE_CHROME

  • MOBILE_SAFARI

device_ostypeString

Required. The operating system running on the specified device.

One of the following:

  • ANDROID
  • IOS
device_idString

Required. The id property assigned to the device by Digital Lab (UFT Mobile).

Return Value

None

See also: