Class DriverFactoryHelper
java.lang.Object
com.shaft.driver.internal.DriverFactory.DriverFactoryHelper
Internal helper responsible for initializing, managing, and closing WebDriver sessions.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a helper instance without an attached WebDriver.DriverFactoryHelper(org.openqa.selenium.WebDriver driver) Creates a helper instance attached to an existing WebDriver session. -
Method Summary
Modifier and TypeMethodDescriptionvoidCloses the currently attached driver session and clears the local driver reference.voidcloseDriver(org.openqa.selenium.WebDriver driver) Closes the given WebDriver session and performs all associated teardown tasks: attaches video recording (if scope is DriverSession), collects WebDriver logs, handles dockerized driver cleanup, and removes the WebDriverManager reference.voidInitializes a driver using the currently configured target browser/mobile settings.voidinitializeDriver(@NonNull DriverFactory.DriverType driverType) Initializes a driver using the supplied driver type and default options.voidinitializeDriver(@NonNull DriverFactory.DriverType driverType, org.openqa.selenium.MutableCapabilities customDriverOptions) Initializes a driver using an explicit driver type and optional custom capabilities.voidinitializeDriver(@NonNull org.openqa.selenium.WebDriver driver) Attaches the helper to an already initialized native WebDriver session.voidinitializeDriver(org.openqa.selenium.MutableCapabilities customDriverOptions) Initializes a driver using configured browser name and custom capabilities.static voidInitializes and normalizes system-level execution properties before driver creation.static booleanChecks to see if the execution is a mobile-native executionstatic booleanChecks to see if the execution is a mobile-web executionstatic booleanChecks to see if the execution is a web-based execution
-
Constructor Details
-
DriverFactoryHelper
public DriverFactoryHelper()Creates a helper instance without an attached WebDriver. -
DriverFactoryHelper
public DriverFactoryHelper(org.openqa.selenium.WebDriver driver) Creates a helper instance attached to an existing WebDriver session.- Parameters:
driver- the active WebDriver session
-
-
Method Details
-
isMobileNativeExecution
public static boolean isMobileNativeExecution()Checks to see if the execution is a mobile-native execution- Returns:
- true if it's a mobile mobile-native execution
-
isMobileWebExecution
public static boolean isMobileWebExecution()Checks to see if the execution is a mobile-web execution- Returns:
- true if it's a mobile mobile-web execution
-
isNotMobileExecution
public static boolean isNotMobileExecution()Checks to see if the execution is a web-based execution- Returns:
- true if it's a web-based execution
-
initializeSystemProperties
public static void initializeSystemProperties()Initializes and normalizes system-level execution properties before driver creation. -
closeDriver
public void closeDriver()Closes the currently attached driver session and clears the local driver reference. -
closeDriver
@Step("Close Driver Session") public void closeDriver(org.openqa.selenium.WebDriver driver) Closes the given WebDriver session and performs all associated teardown tasks: attaches video recording (if scope is DriverSession), collects WebDriver logs, handles dockerized driver cleanup, and removes the WebDriverManager reference.The method handles the following edge cases gracefully:
- Driver already closed — logs at DEBUG level and continues
nulldriver — logs an informational message and returns- Exceptions during
close()orquit()— caught and logged so the remaining teardown (log attachment, state cleanup) still executes
- Parameters:
driver- the WebDriver instance to close; ifnull, the method is a no-op
-
initializeDriver
public void initializeDriver()Initializes a driver using the currently configured target browser/mobile settings. -
initializeDriver
Initializes a driver using the supplied driver type and default options.- Parameters:
driverType- the desired driver type
-
initializeDriver
public void initializeDriver(org.openqa.selenium.MutableCapabilities customDriverOptions) Initializes a driver using configured browser name and custom capabilities.- Parameters:
customDriverOptions- custom capabilities to merge into default options
-
initializeDriver
public void initializeDriver(@NonNull @NonNull DriverFactory.DriverType driverType, org.openqa.selenium.MutableCapabilities customDriverOptions) Initializes a driver using an explicit driver type and optional custom capabilities.- Parameters:
driverType- the desired driver typecustomDriverOptions- custom capabilities to merge into default options
-
initializeDriver
public void initializeDriver(@NonNull @NonNull org.openqa.selenium.WebDriver driver) Attaches the helper to an already initialized native WebDriver session.- Parameters:
driver- existing WebDriver instance
-