Class BrowserFactory
A class for creating an IBrowser instance.
Inherited Members
Namespace: HP.LFT.SDK.Web
Assembly: HP.LFT.SDK.dll
Syntax
public static class BrowserFactory
Methods
Attach(BrowserDescription)
Returns a new IBrowser instance that is attached to a browser tab that was not opened by OpenText Functional Testing for Developers (for example, a browser tab that was opened manually or by the AUT).
Declaration
public static IBrowser Attach(BrowserDescription description)
Parameters
| Type | Name | Description |
|---|---|---|
| BrowserDescription | description | BrowserDescription for filtering the open tabs. |
Returns
| Type | Description |
|---|---|
| IBrowser | IBrowser for the launched browser if a single matching browser was found. |
Remarks
BrowserDescription is used only when attaching to the browser so transient properties like Url
and Title can be used.
OpenText Functional Testing for Developers recognizes browser windows and tabs that it opens (for example, via Launch(BrowserType)).
If a browser is opened outside of the OpenText Functional Testing for Developers context, you need to use the Attach(BrowserDescription) method to acquire the browser tab or window.
Examples:
- A browser tab was opened manually while setting up a scenario prior to running a test.
- A test step clicks a link in the AUT that opens a new or replacement browser tab or window.
Exceptions
| Type | Condition |
|---|---|
| ReplayObjectNotFoundException | No open browser tab matches the description. |
| ReplayObjectNotUniqueException | More than one browser tab matches the description. |
GetAllOpenBrowsers(BrowserDescription)
Returns a collection of all open IBrowser that matches the BrowserDescription.
Declaration
public static IBrowser[] GetAllOpenBrowsers(BrowserDescription description)
Parameters
| Type | Name | Description |
|---|---|---|
| BrowserDescription | description | BrowserDescription to filter the opened tabs against. If null, all open browsers will be returned. |
Returns
| Type | Description |
|---|---|
| IBrowser[] | A collection of IBrowser objects that are open and match the description. |
Remarks
The BrowserDescription is used only when attaching to the browser so transient properties like Url and Titlecan be used.
Launch(BrowserDescription)
Launches a new browser tab returning an instance of IBrowser for the launched browser.
Declaration
public static IBrowser Launch(BrowserDescription description)
Parameters
| Type | Name | Description |
|---|---|---|
| BrowserDescription | description | The description of the browser to launch. |
Returns
| Type | Description |
|---|---|
| IBrowser | The IBrowser for the launched browser |
Remarks
When working in a grid configuration, the browser description can also include capabilities that describe an environment. For details on how to describe the capabilities, see https://admhelp.microfocus.com/uftdev/en/latest/HelpCenter/Default.htm#cshid=grid-ready. An environment that matches the browserDesc argument is locked and the specified browser is launched on that environment. The returned browser instance is valid until the tab is closed.
Launch(BrowserDescription, IEnvironment)
Launches a new browser tab returning an instance of IBrowser for the launched browser.
Declaration
public static IBrowser Launch(BrowserDescription description, IEnvironment environment)
Parameters
| Type | Name | Description |
|---|---|---|
| BrowserDescription | description | The description of the browser to launch. |
| IEnvironment | environment | AUT environment. When working in a grid configuration, this is an environment previously locked using Get(EnvironmentDescription). |
Returns
| Type | Description |
|---|---|
| IBrowser | The IBrowser for the launched browser |
Remarks
The returned browser instance is valid until the tab is closed.
Launch(BrowserType)
Launches a new browser tab returning an instance of IBrowser for the launched browser.
Declaration
public static IBrowser Launch(BrowserType browserType)
Parameters
| Type | Name | Description |
|---|---|---|
| BrowserType | browserType | Type of browser to launch: Possible values: BrowserType |
Returns
| Type | Description |
|---|---|
| IBrowser | The IBrowser for the launched browser |
Remarks
When working in a grid configuration, an environment that has this browser is locked. The returned browser instance is valid until the tab is closed.
Launch(BrowserType, IEnvironment)
Launches a new browser tab returning an instance of IBrowser for the launched browser.
Declaration
public static IBrowser Launch(BrowserType browserType, IEnvironment environment)
Parameters
| Type | Name | Description |
|---|---|---|
| BrowserType | browserType | Type of browser to launch: Possible values: BrowserType |
| IEnvironment | environment | AUT environment |
Returns
| Type | Description |
|---|---|
| IBrowser | The IBrowser for the launched browser |
Remarks
The returned browser instance is valid until the tab is closed.
Launch(BrowserType, bool)
Launches a new browser tab in incognito/private mode if flag is set, returning an instance of IBrowser for the launched browser.
Declaration
public static IBrowser Launch(BrowserType browserType, bool incognito)
Parameters
| Type | Name | Description |
|---|---|---|
| BrowserType | browserType | Type of browser to launch: Possible values: BrowserType |
| bool | incognito | If true, launches the browser in incognito/private mode. |
Returns
| Type | Description |
|---|---|
| IBrowser | The IBrowser for the launched browser |
Remarks
The returned browser instance is valid until the tab is closed. Incognito/private mode is only supported for Chrome, Firefox and Edge desktop browsers. The browser agent extension needs to be allowed to run in incognito mode.
Launch(BrowserType, string)
Launches a new browser tab with the specified user profile, returning an instance of IBrowser for the launched browser.
Declaration
public static IBrowser Launch(BrowserType browserType, string profileName)
Parameters
| Type | Name | Description |
|---|---|---|
| BrowserType | browserType | Type of browser to launch: Possible values: BrowserType |
| string | profileName | The name of the browser user profile to use. |
Returns
| Type | Description |
|---|---|
| IBrowser | The IBrowser for the launched browser |
Remarks
The returned browser instance is valid until the tab is closed. Only supported for Chrome, Firefox and Edge desktop browsers. For Firefox, use the profile name as shown in Firefox's Profile Manager. For Chrome and Edge, use the profile folder name found in the Local AppData directory for each respective browser. The browser agent extension needs to be activated on each profile used.