Class DriverFactory

java.lang.Object
com.shaft.driver.DriverFactory

public class DriverFactory extends Object
Factory for creating and managing WebDriver instances in SHAFT.

This class handles driver initialization for local browsers, remote Selenium Grid, BrowserStack, and LambdaTest. It also provides factory methods for API, CLI, and database drivers.

The factory automatically reads configuration from SHAFT's properties system and supports last-minute property overrides from TestNG suite XML.

See Also:
  • Constructor Details

    • DriverFactory

      public DriverFactory()
  • Method Details

    • reloadProperties

      public static boolean reloadProperties()
    • getAPIDriver

      public static RestActions getAPIDriver(String serviceURI)
      Creates a new API instance to facilitate using the Rest Actions Library
      Parameters:
      serviceURI - the base URI of the target web service
      Returns:
      rest actions instance that can be used to chain and build your api request
    • getTerminalDriver

      public static TerminalActions getTerminalDriver()
      Creates a new local Terminal instance to facilitate using the Terminal Actions Library
      Returns:
      local terminal driver instance
    • getDatabaseDriver

      public static DatabaseActions getDatabaseDriver(DatabaseActions.DatabaseType databaseType, String ip, String port, String name, String username, String password)
      Creates a new Database driver instance to facilitate using the Database Actions Library
      Parameters:
      databaseType - database type that you want to connect with: DatabaseType.MY_SQL ,SQL_SERVER,POSTGRES_SQL.
      ip - IP address that has database installation that we need to connect to (e.g. 72.55.136.25)
      port - port of database installation on the server (e.g. 3306)
      name - database name that you need to connect to
      username - database username
      password - password of database user
      Returns:
      new database driver instance
    • getHelper

      public DriverFactoryHelper getHelper()
      Read the target Selenium WebDriver value from the execution.properties file
      Returns:
      a new Selenium WebDriver instance
    • getDriver

      public org.openqa.selenium.WebDriver getDriver()
    • getHelper

      public DriverFactoryHelper getHelper(DriverFactory.DriverType driverType)
      Creates a new Selenium WebDriver instance with custom driver type
      Parameters:
      driverType - one of the supported driver types
      Returns:
      a new Selenium WebDriver instance
    • getHelper

      public DriverFactoryHelper getHelper(DriverFactory.DriverType driverType, org.openqa.selenium.MutableCapabilities customDriverOptions)
      Creates a new Selenium WebDriver instance with custom driver type and options
      Parameters:
      driverType - one of the supported driver types
      customDriverOptions - the custom options that will be used to create this new driver instance, or null to use the default
      Returns:
      a new Selenium WebDriver instance
    • getHelper

      public DriverFactoryHelper getHelper(org.openqa.selenium.WebDriver driver)
      Attaches the Engine to an already up and running selenium webdriver instance
      Parameters:
      driver - an already initialized native selenium webdriver instance
      Returns:
      a helper instance to be used for driver manipulation