Package com.hp.lft.sdk.web
Class BrowserFactory
java.lang.Object
com.hp.lft.sdk.web.BrowserFactory
A class for creating a
Browser
instance.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Browser
attach
(BrowserDescription description) Attaches a newBrowser
instance to a previously opened browser tab.static Browser[]
getAllOpenBrowsers
(BrowserDescription description) Returns an array of all open browsers that match the givenBrowserDescription
.static Browser
launch
(BrowserDescription browserDesc) Launches a new browser tab returning an instance ofBrowser
for the launched browser.static Browser
launch
(BrowserDescription browserDesc, Environment env) Launches a new browser tab on the specified environment and returns an instance ofBrowser
for the launched browser.static Browser
launch
(BrowserType browserType) Launches a new browser tab returning an instance ofBrowser
for the launched browser.static Browser
launch
(BrowserType browserType, Environment environment) Launches a new browser tab on the specified environment and returns an instance ofBrowser
for the launched browser.
-
Constructor Details
-
BrowserFactory
public BrowserFactory()
-
-
Method Details
-
launch
Launches a new browser tab returning an instance ofBrowser
for the launched browser.
When working in a grid configuration, an environment that has this browser is locked for use.
The returned browser instance is valid until the tab is closed.- Parameters:
browserType
- The type of browser to launch. Possible values:BrowserType
- Returns:
- The
Browser
for the launched browser. - Throws:
GeneralLeanFtException
- if error occurs during execution
-
launch
public static Browser launch(BrowserType browserType, Environment environment) throws GeneralLeanFtException Launches a new browser tab on the specified environment and returns an instance ofBrowser
for the launched browser.
The returned browser instance is valid until the tab is closed.- Parameters:
browserType
- The type of browser to launch. Possible values:BrowserType
environment
- The environment on which to open the browser. When working in a grid configuration, this is an environment previously locked usingEnvironmentFactory.get(com.hp.lft.sdk.EnvironmentDescription)
.- Returns:
- The
Browser
for the launched browser. - Throws:
GeneralLeanFtException
- if error occurs during execution.
-
launch
Launches a new browser tab returning an instance ofBrowser
for the launched browser.
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/Content/HowTo/LeanFT-grid-ready-tests.htm#Build.
An environment that matches the browserDesc argument is locked for use and the specified browser is launched on that environment.
The returned browser instance is valid until the tab is closed.- Parameters:
browserDesc
- The description of the browser to launch. When working in a grid configuration you can add environment capabilities to this argument.- Returns:
- The
Browser
for the launched browser. - Throws:
GeneralLeanFtException
- if error occurs during execution.
-
launch
public static Browser launch(BrowserDescription browserDesc, Environment env) throws GeneralLeanFtException Launches a new browser tab on the specified environment and returns an instance ofBrowser
for the launched browser. If the browser description includes capabilities to describe an environment, these are ignored.
The returned browser instance is valid until the tab is closed.- Parameters:
browserDesc
- The description of the browser to launch.env
- The environment on which to open the browser. When working in a grid configuration, this is an environment previously locked usingEnvironmentFactory.get(com.hp.lft.sdk.EnvironmentDescription)
.- Returns:
- The
Browser
for the launched browser. - Throws:
GeneralLeanFtException
- if error occurs during execution.
-
attach
Attaches a newBrowser
instance to a previously opened browser tab.
The BrowserDescription is used only when attaching to the browser, so transient values likeBrowserDescription.setUrl()
orBrowserDescription.setTitle()
can be used.- Parameters:
description
-BrowserDescription
for filtering the open tabs.- Returns:
- a Browser instance representing the matching browser.
- Throws:
GeneralLeanFtException
- if error occurs during execution
-
getAllOpenBrowsers
public static Browser[] getAllOpenBrowsers(BrowserDescription description) throws GeneralLeanFtException Returns an array of all open browsers that match the givenBrowserDescription
.
TheBrowserDescription
is used only when attaching to the browser, so transient values like BrowserDescription.setUrl() or BrowserDescription.setTitle() can be used.- Parameters:
description
- the description to filter the open tabs against. If null, all open browsers will be returned.- Returns:
- an array of all open browsers that match the given
BrowserDescription
. - Throws:
GeneralLeanFtException
- if error occurs during execution
-