Class SHAFT.GUI.WebDriver
java.lang.Object
com.shaft.driver.SHAFT.GUI.WebDriver
- Enclosing class:
SHAFT.GUI
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 ClassesModifier and TypeClassDescriptionclassProvides asynchronous element actions that run without blocking the calling thread. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new WebDriver session using the browser type configured in the execution properties.WebDriver(DriverFactory.DriverType driverType) 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 TypeMethodDescriptionalert()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).async()Returns an async-actions entry point for performing element interactions asynchronously.browser()Returns a browser actions object for navigation, window management, cookies, and screenshots.element()Returns an element actions object for interacting with web elements (click, type, select, etc.).org.openqa.selenium.WebDriverReturns the current Selenium WebDriver instance for custom manipulation.voidquit()Terminates the current WebDriver session and releases all associated resources.touch()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).
-
Constructor Details
-
WebDriver
public WebDriver()Creates a new WebDriver session using the browser type configured in the execution properties. -
WebDriver
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 createmutableCapabilities- 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
-
touch
Returns a touch actions object for mobile gesture interactions (swipe, tap, pinch, etc.).- Returns:
- a
TouchActionsinstance scoped to this driver session
-
browser
Returns a browser actions object for navigation, window management, cookies, and screenshots.- Returns:
- a
BrowserActionsinstance scoped to this driver session
-
alert
Returns an alert actions object for interacting with JavaScript alert, confirm, and prompt dialogs.- Returns:
- an
AlertActionsinstance scoped to this driver session
-
assertThat
Starts building a hard assertion (the test fails immediately on mismatch).- Returns:
- a
WizardHelpers.WebDriverAssertionsbuilder 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.WebDriverVerificationsbuilder
-
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
enableTrueNativeModeis disabled. Because most local Selenium drivers extendRemoteWebDriver, they will typically be returned undecorated.- Returns:
- the underlying
WebDriverinstance for this session
-
async
Returns an async-actions entry point for performing element interactions asynchronously.- Returns:
- an
SHAFT.GUI.WebDriver.Asyncinstance scoped to this driver session
-