Class DriverFactory
java.lang.Object
com.shaft.driver.DriverFactory
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumList of the supported driver types for execution -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic RestActionsgetAPIDriver(String serviceURI) Creates a new API instance to facilitate using the Rest Actions Librarystatic DatabaseActionsgetDatabaseDriver(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 Libraryorg.openqa.selenium.WebDriverRead the target Selenium WebDriver value from the execution.properties filegetHelper(DriverFactory.DriverType driverType) Creates a new Selenium WebDriver instance with custom driver typegetHelper(DriverFactory.DriverType driverType, org.openqa.selenium.MutableCapabilities customDriverOptions) Creates a new Selenium WebDriver instance with custom driver type and optionsgetHelper(org.openqa.selenium.WebDriver driver) Attaches the Engine to an already up and running selenium webdriver instancestatic TerminalActionsCreates a new local Terminal instance to facilitate using the Terminal Actions Librarystatic boolean
-
Constructor Details
-
DriverFactory
public DriverFactory()
-
-
Method Details
-
reloadProperties
public static boolean reloadProperties() -
getAPIDriver
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
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 tousername- database usernamepassword- password of database user- Returns:
- new database driver instance
-
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
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 typescustomDriverOptions- 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
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
-