Class SHAFT.GUI.WebDriver
java.lang.Object
com.shaft.driver.SHAFT.GUI.WebDriver
- All Implemented Interfaces:
SHAFT.GUI.Driver, DriverContract
- 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 TypeMethodDescriptionPerforms an enabled natural-language browser, element, or touch action.alert()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).Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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
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).- Specified by:
quitin interfaceDriverContract
-
element
Returns an element actions object for interacting with web elements (click, type, select, etc.).- Specified by:
elementin interfaceDriverContract- Returns:
- an
Actionsinstance scoped to this driver session
-
touch
Returns a touch actions object for mobile gesture interactions (swipe, tap, pinch, etc.).- Specified by:
touchin interfaceDriverContract- Returns:
- a
TouchActionsinstance scoped to this driver session
-
browser
Returns a browser actions object for navigation, window management, cookies, and screenshots.- Specified by:
browserin interfaceDriverContract- Returns:
- a
BrowserActionsinstance scoped to this driver session
-
act
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:
actin interfaceDriverContract- Specified by:
actin interfaceSHAFT.GUI.Driver- Parameters:
intent- the natural-language action intentargs- optional action arguments referenced by the intent- Returns:
- this driver instance for fluent chaining
-
alert
Returns an alert actions object for interacting with JavaScript alert, confirm, and prompt dialogs.- Specified by:
alertin interfaceDriverContract- Returns:
- an
AlertActionsinstance scoped to this driver session
-
assertThat
Starts building a hard assertion (the test fails immediately on mismatch).- Specified by:
assertThatin interfaceDriverContract- 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).- Specified by:
verifyThatin interfaceDriverContract- 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.- Specified by:
getDriverin interfaceDriverContract- 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
-