Class SHAFT.GUI.WebDriver

java.lang.Object
com.shaft.driver.SHAFT.GUI.WebDriver
Enclosing class:
SHAFT.GUI

public static class SHAFT.GUI.WebDriver extends Object
Manages a Selenium/Appium WebDriver session and exposes fluent actions for browser navigation, element interaction, touch gestures, alert handling, and assertions.

Create one instance per test method (typically in a @BeforeMethod), perform actions via the fluent API, and call quit() in @AfterMethod to release resources.

Usage example:

SHAFT.GUI.WebDriver driver = new SHAFT.GUI.WebDriver();
driver.browser().navigateToURL("https://example.com");
driver.element().click(By.id("submit"));
driver.assertThat().browser().title().contains("Success");
driver.quit();
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    class 
    Provides asynchronous element actions that run without blocking the calling thread.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new WebDriver session using the browser type configured in the execution properties.
    Creates a new WebDriver session with the specified driver type.
    WebDriver(DriverFactory.DriverType driverType, org.openqa.selenium.MutableCapabilities mutableCapabilities)
    Creates a new WebDriver session with the specified driver type and custom capabilities.
    WebDriver(org.openqa.selenium.WebDriver driver)
    Wraps an existing Selenium WebDriver instance for use with SHAFT's fluent API.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns an alert actions object for interacting with JavaScript alert, confirm, and prompt dialogs.
    Starts building a hard assertion (the test fails immediately on mismatch).
    Returns an async-actions entry point for performing element interactions asynchronously.
    Returns a browser actions object for navigation, window management, cookies, and screenshots.
    Returns an element actions object for interacting with web elements (click, type, select, etc.).
    org.openqa.selenium.WebDriver
    Returns the current Selenium WebDriver instance for custom manipulation.
    void
    Terminates the current WebDriver session and releases all associated resources.
    Returns a touch actions object for mobile gesture interactions (swipe, tap, pinch, etc.).
    Starts building a soft verification (failures are collected and reported at the end of the test).

    Methods inherited from class Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • WebDriver

      public WebDriver()
      Creates a new WebDriver session using the browser type configured in the execution properties.
    • WebDriver

      public WebDriver(DriverFactory.DriverType driverType)
      Creates a new WebDriver session with the specified driver type.
      Parameters:
      driverType - the type of driver to create (e.g., DriverFactory.DriverType.CHROME, DriverFactory.DriverType.FIREFOX)
    • WebDriver

      public WebDriver(DriverFactory.DriverType driverType, org.openqa.selenium.MutableCapabilities mutableCapabilities)
      Creates a new WebDriver session with the specified driver type and custom capabilities.
      Parameters:
      driverType - the type of driver to create
      mutableCapabilities - custom capabilities to merge into the session
    • WebDriver

      public WebDriver(org.openqa.selenium.WebDriver driver)
      Wraps an existing Selenium WebDriver instance for use with SHAFT's fluent API.
      Parameters:
      driver - an already-initialized Selenium WebDriver instance
  • Method Details

    • quit

      public void quit()
      Terminates the current WebDriver session and releases all associated resources. Should be called in @AfterMethod (TestNG) or @AfterEach (JUnit 5).
    • element

      public Actions element()
      Returns an element actions object for interacting with web elements (click, type, select, etc.).
      Returns:
      an Actions instance scoped to this driver session
    • touch

      public TouchActions touch()
      Returns a touch actions object for mobile gesture interactions (swipe, tap, pinch, etc.).
      Returns:
      a TouchActions instance scoped to this driver session
    • browser

      public BrowserActions browser()
      Returns a browser actions object for navigation, window management, cookies, and screenshots.
      Returns:
      a BrowserActions instance scoped to this driver session
    • alert

      public AlertActions alert()
      Returns an alert actions object for interacting with JavaScript alert, confirm, and prompt dialogs.
      Returns:
      an AlertActions instance scoped to this driver session
    • assertThat

      public WizardHelpers.WebDriverAssertions assertThat()
      Starts building a hard assertion (the test fails immediately on mismatch).
      Returns:
      a WizardHelpers.WebDriverAssertions builder for browser, element, and other assertions
    • verifyThat

      Starts building a soft verification (failures are collected and reported at the end of the test).
      Returns:
      a WizardHelpers.WebDriverVerifications builder
    • getDriver

      public org.openqa.selenium.WebDriver getDriver()
      Returns the current Selenium WebDriver instance for custom manipulation.

      Note: Event-firing decoration is only applied for non-remote, non-Appium drivers when enableTrueNativeMode is disabled. Because most local Selenium drivers extend RemoteWebDriver, they will typically be returned undecorated.

      Returns:
      the underlying WebDriver instance for this session
    • async

      public SHAFT.GUI.WebDriver.Async async()
      Returns an async-actions entry point for performing element interactions asynchronously.
      Returns:
      an SHAFT.GUI.WebDriver.Async instance scoped to this driver session