Class SHAFT.GUI.WebDriver

java.lang.Object
com.shaft.driver.SHAFT.GUI.WebDriver
All Implemented Interfaces:
SHAFT.GUI.Driver, DriverContract
Enclosing class:
SHAFT.GUI

public static class SHAFT.GUI.WebDriver extends Object implements SHAFT.GUI.Driver
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
    act(String intent, Object... args)
    Performs an enabled natural-language browser, element, or touch action.
    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

    Methods inherited from interface DriverContract

    getNativeContext, getNativeDriver
  • 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).
      Specified by:
      quit in interface DriverContract
    • element

      public Actions element()
      Returns an element actions object for interacting with web elements (click, type, select, etc.).
      Specified by:
      element in interface DriverContract
      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.).
      Specified by:
      touch in interface DriverContract
      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.
      Specified by:
      browser in interface DriverContract
      Returns:
      a BrowserActions instance scoped to this driver session
    • act

      public SHAFT.GUI.WebDriver act(String intent, Object... args)
      Performs an enabled natural-language browser, element, or touch action.

      The intent is first converted into a structured SHAFT action plan, validated against the configured trust threshold, and then executed through the normal deterministic SHAFT action APIs. User-supplied arguments are passed to the plan as data values and are not included in natural-action report messages.

      driver.act("Login with valid credentials", username, password);
      
      Specified by:
      act in interface DriverContract
      Specified by:
      act in interface SHAFT.GUI.Driver
      Parameters:
      intent - the natural-language action intent
      args - optional action arguments referenced by the intent
      Returns:
      this driver instance for fluent chaining
    • alert

      public AlertActions alert()
      Returns an alert actions object for interacting with JavaScript alert, confirm, and prompt dialogs.
      Specified by:
      alert in interface DriverContract
      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).
      Specified by:
      assertThat in interface DriverContract
      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).
      Specified by:
      verifyThat in interface DriverContract
      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.

      Specified by:
      getDriver in interface DriverContract
      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