com.hp.lft.sdk.web

Class BrowserFactory



  • public class BrowserFactory
    extends Object
    A class for creating a Browser instance.
    • Constructor Detail

      • BrowserFactory

        public BrowserFactory()
    • Method Detail

      • launch

        public static Browser launch(BrowserType browserType)
                              throws GeneralLeanFtException
        Launches a new browser tab returning an instance of Browser for the launched browser.
        When working in a grid configuration UFT Developer locks an environment that has this browser.
        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 of Browser 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 using EnvironmentFactory.get.
        Returns:
        The Browser for the launched browser.
        Throws:
        GeneralLeanFtException - if error occurs during execution.
      • launch

        public static Browser launch(BrowserDescription browserDesc)
                              throws GeneralLeanFtException
        Launches a new browser tab returning an instance of Browser 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.
        UFT Developer locks an environment that matches the browserDesc argument and launches the specified browser 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.
        For Chrome and Firefox, the browserDesc can include the following capability definitions:
        - A profile_proxy capability, which specifies the address of a web proxy for the browser to use. This results in the use of a separate browser profile, which does not share cookies an so on with the default browsers.
        - A profile capability, set to true instructing UFT Developer to open the browser with a temporary profile, or false to use the browser's default profile behavior. The default value for the profile capability is false.
        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 of Browser 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 using EnvironmentFactory.get.
        Returns:
        The Browser for the launched 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 given BrowserDescription.
        The BrowserDescription 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