Class BrowserFactory

java.lang.Object
com.hp.lft.sdk.web.BrowserFactory

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

    • BrowserFactory

      public BrowserFactory()
  • Method Details

    • 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, 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, Boolean incognito) throws GeneralLeanFtException
      Launches a new browser tab in incognito/private mode if flag is set, returning an instance of Browser for the launched browser.
      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.
      Parameters:
      browserType - The type of browser to launch. Possible values: BrowserType
      incognito - If true, launches the browser in incognito/private mode.
      Returns:
      The Browser for the launched browser.
      Throws:
      GeneralLeanFtException - if error occurs during execution
    • launch

      public static Browser launch(BrowserType browserType, String profileName) throws GeneralLeanFtException
      Launches a new browser tab with the specified user profile, returning an instance of Browser for the launched browser.
      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.
      The browser agent extension needs to be activated on each profile used.
      Parameters:
      browserType - The type of browser to launch. Possible values: BrowserType
      profileName - The name of the browser user profile to use.
      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(com.hp.lft.sdk.EnvironmentDescription).
      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/Default.htm#cshid=grid-ready.
      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 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(com.hp.lft.sdk.EnvironmentDescription).
      Returns:
      The Browser for the launched browser.
      Throws:
      GeneralLeanFtException - if error occurs during execution.
    • attach

      public static Browser attach(BrowserDescription description) throws GeneralLeanFtException
      Attaches a new Browser instance to a previously opened browser tab.
      The BrowserDescription is used only when attaching to the browser, so transient values like BrowserDescription.setUrl() or BrowserDescription.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 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