Class AsyncElementActions
ElementActions operations.
Each action method schedules the underlying ElementActions call on a new virtual thread
and returns this immediately, allowing the caller to queue multiple actions in parallel
before waiting for them all to finish via synchronize(), join(), or sync().
Thread safety: each AsyncElementActions instance maintains its own internal list
of virtual threads, so instances must not be shared across test threads.
Example usage:
driver.async().element()
.type(firstNameField, "John")
.type(lastNameField, "Doe")
.click(submitButton)
.synchronize();
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a newAsyncElementActionsbound to the given driver helper. -
Method Summary
Modifier and TypeMethodDescriptioncaptureScreenshot(org.openqa.selenium.By elementLocator) Asynchronously captures a screenshot of the element identified byelementLocatorand attaches it to the Allure report.clear(org.openqa.selenium.By elementLocator) Asynchronously clears the content of the element identified byelementLocator.click(org.openqa.selenium.By elementLocator) Asynchronously clicks the element identified byelementLocator.clickAndHold(org.openqa.selenium.By elementLocator) Asynchronously clicks and holds the mouse button down on the element identified byelementLocatorwithout releasing it, which is useful for drag operations or long-press interactions.clickUsingJavascript(org.openqa.selenium.By elementLocator) Asynchronously clicks the element identified byelementLocatorusing JavaScript.clipboardActions(org.openqa.selenium.By elementLocator, ClipboardAction action) Asynchronously performs the specified clipboard action (e.g., copy, paste, cut) on the element identified byelementLocator.doubleClick(org.openqa.selenium.By elementLocator) Asynchronously double-clicks the element identified byelementLocator.dragAndDrop(org.openqa.selenium.By sourceElementLocator, org.openqa.selenium.By destinationElementLocator) Asynchronously drags the element identified bysourceElementLocatorand drops it onto the element identified bydestinationElementLocator.hover(org.openqa.selenium.By elementLocator) Asynchronously moves the mouse cursor over the element identified byelementLocator, triggering any hover-based UI state (e.g., tooltips, drop-down menus).join()Alias forsynchronize().Asynchronously selects the option matchingtextin the drop-down element identified byelementLocator.setValueUsingJavaScript(org.openqa.selenium.By elementLocator, String value) Asynchronously sets thevalueattribute of the element identified byelementLocatordirectly via JavaScript, bypassing normal input events.submitFormUsingJavaScript(org.openqa.selenium.By elementLocator) Asynchronously submits the form that contains the element identified byelementLocatorusing JavaScript, bypassing standard form-submission validation.sync()Alias forsynchronize().Blocks the calling thread until all previously queued asynchronous actions have finished executing on their respective virtual threads.Asynchronously types the given text into the element identified byelementLocator.typeAppend(org.openqa.selenium.By elementLocator, String text) Asynchronously appends the given text to the current value of the element identified byelementLocatorwithout clearing its existing content first.typeFileLocationForUpload(org.openqa.selenium.By elementLocator, String filePath) Asynchronously types the absolute path of a local file into the file-upload input element identified byelementLocator, triggering the browser's file selection mechanism.typeSecure(org.openqa.selenium.By elementLocator, String text) Asynchronously types the given text into the element identified byelementLocatorin a secure manner, masking the typed characters in logs and reports to protect sensitive data such as passwords.Methods inherited from class FluentWebDriverAction
alert, and, browser, element, initialize, initialize, initialize, initialize, performAlertAction, performBrowserAction, performElementAction, performTouchAction, touch
-
Constructor Details
-
AsyncElementActions
Constructs a newAsyncElementActionsbound to the given driver helper.Example:
AsyncElementActions asyncActions = new AsyncElementActions(driverFactoryHelper);- Parameters:
helper- theDriverFactoryHelperthat provides access to the underlying WebDriver session
-
-
Method Details
-
type
Asynchronously types the given text into the element identified byelementLocator.The action is executed on a new virtual thread; the current thread is not blocked.
Example:
asyncActions.type(By.id("username"), "testUser");- Parameters:
elementLocator- theBylocator used to find the target elementtext- the text to type into the element- Returns:
- this
AsyncElementActionsinstance for fluent chaining
-
click
Asynchronously clicks the element identified byelementLocator.Example:
asyncActions.click(By.id("submitButton"));- Parameters:
elementLocator- theBylocator used to find the target element- Returns:
- this
AsyncElementActionsinstance for fluent chaining
-
select
Asynchronously selects the option matchingtextin the drop-down element identified byelementLocator.Example:
asyncActions.select(By.id("countryDropdown"), "Egypt");- Parameters:
elementLocator- theBylocator used to find the<select>elementtext- the visible text of the option to select- Returns:
- this
AsyncElementActionsinstance for fluent chaining
-
clear
Asynchronously clears the content of the element identified byelementLocator.Example:
asyncActions.clear(By.id("searchInput"));- Parameters:
elementLocator- theBylocator used to find the target element- Returns:
- this
AsyncElementActionsinstance for fluent chaining
-
doubleClick
Asynchronously double-clicks the element identified byelementLocator.Example:
asyncActions.doubleClick(By.id("editableCell"));- Parameters:
elementLocator- theBylocator used to find the target element- Returns:
- this
AsyncElementActionsinstance for fluent chaining
-
clickUsingJavascript
Asynchronously clicks the element identified byelementLocatorusing JavaScript.Useful when native WebDriver click is intercepted by overlapping elements.
Example:
asyncActions.clickUsingJavascript(By.id("hiddenButton"));- Parameters:
elementLocator- theBylocator used to find the target element- Returns:
- this
AsyncElementActionsinstance for fluent chaining
-
clipboardActions
public AsyncElementActions clipboardActions(org.openqa.selenium.By elementLocator, ClipboardAction action) Asynchronously performs the specified clipboard action (e.g., copy, paste, cut) on the element identified byelementLocator.Example:
asyncActions.clipboardActions(By.id("textArea"), ClipboardAction.COPY);- Parameters:
elementLocator- theBylocator used to find the target elementaction- theClipboardActionto perform (e.g.,COPY,PASTE,CUT)- Returns:
- this
AsyncElementActionsinstance for fluent chaining
-
captureScreenshot
Asynchronously captures a screenshot of the element identified byelementLocatorand attaches it to the Allure report.Example:
asyncActions.captureScreenshot(By.id("chart"));- Parameters:
elementLocator- theBylocator used to find the target element- Returns:
- this
AsyncElementActionsinstance for fluent chaining
-
hover
Asynchronously moves the mouse cursor over the element identified byelementLocator, triggering any hover-based UI state (e.g., tooltips, drop-down menus).Example:
asyncActions.hover(By.id("menuItem"));- Parameters:
elementLocator- theBylocator used to find the target element- Returns:
- this
AsyncElementActionsinstance for fluent chaining
-
typeAppend
Asynchronously appends the given text to the current value of the element identified byelementLocatorwithout clearing its existing content first.Example:
asyncActions.typeAppend(By.id("notes"), " additional text");- Parameters:
elementLocator- theBylocator used to find the target elementtext- the text to append to the element's current value- Returns:
- this
AsyncElementActionsinstance for fluent chaining
-
clickAndHold
Asynchronously clicks and holds the mouse button down on the element identified byelementLocatorwithout releasing it, which is useful for drag operations or long-press interactions.Example:
asyncActions.clickAndHold(By.id("draggableHandle"));- Parameters:
elementLocator- theBylocator used to find the target element- Returns:
- this
AsyncElementActionsinstance for fluent chaining
-
setValueUsingJavaScript
public AsyncElementActions setValueUsingJavaScript(org.openqa.selenium.By elementLocator, String value) Asynchronously sets thevalueattribute of the element identified byelementLocatordirectly via JavaScript, bypassing normal input events.This is useful for read-only or JavaScript-rendered input fields that cannot be interacted with through the standard WebDriver API.
Example:
asyncActions.setValueUsingJavaScript(By.id("hiddenInput"), "injectedValue");- Parameters:
elementLocator- theBylocator used to find the target elementvalue- the value to assign to the element'svalueattribute- Returns:
- this
AsyncElementActionsinstance for fluent chaining
-
typeSecure
Asynchronously types the given text into the element identified byelementLocatorin a secure manner, masking the typed characters in logs and reports to protect sensitive data such as passwords.Example:
asyncActions.typeSecure(By.id("passwordField"), "s3cr3tP@ssword");- Parameters:
elementLocator- theBylocator used to find the target elementtext- the sensitive text to type (will be masked in reports)- Returns:
- this
AsyncElementActionsinstance for fluent chaining
-
submitFormUsingJavaScript
Asynchronously submits the form that contains the element identified byelementLocatorusing JavaScript, bypassing standard form-submission validation.Example:
asyncActions.submitFormUsingJavaScript(By.id("loginForm"));- Parameters:
elementLocator- theBylocator used to find an element within the target form- Returns:
- this
AsyncElementActionsinstance for fluent chaining
-
typeFileLocationForUpload
public AsyncElementActions typeFileLocationForUpload(org.openqa.selenium.By elementLocator, String filePath) Asynchronously types the absolute path of a local file into the file-upload input element identified byelementLocator, triggering the browser's file selection mechanism.Example:
asyncActions.typeFileLocationForUpload(By.id("fileInput"), "/home/user/documents/report.pdf");- Parameters:
elementLocator- theBylocator used to find the file-input elementfilePath- the absolute path to the file to upload- Returns:
- this
AsyncElementActionsinstance for fluent chaining
-
dragAndDrop
public AsyncElementActions dragAndDrop(org.openqa.selenium.By sourceElementLocator, org.openqa.selenium.By destinationElementLocator) Asynchronously drags the element identified bysourceElementLocatorand drops it onto the element identified bydestinationElementLocator.Example:
asyncActions.dragAndDrop(By.id("draggableCard"), By.id("dropZone"));- Parameters:
sourceElementLocator- theBylocator used to find the element to dragdestinationElementLocator- theBylocator used to find the drop target- Returns:
- this
AsyncElementActionsinstance for fluent chaining
-
join
Alias forsynchronize(). Blocks the calling thread until all queued asynchronous actions have completed.Example:
asyncActions.type(firstField, "value1") .click(submitButton) .join();- Returns:
- this
AsyncElementActionsinstance for fluent chaining - See Also:
-
synchronize
Blocks the calling thread until all previously queued asynchronous actions have finished executing on their respective virtual threads.Any
InterruptedExceptionthrown while waiting for a thread to join is caught and logged via SHAFT's internal reporting utilities.Example:
asyncActions.type(firstField, "value1") .type(secondField, "value2") .synchronize();- Returns:
- this
AsyncElementActionsinstance for fluent chaining - See Also:
-
sync
Alias forsynchronize(). Blocks the calling thread until all queued asynchronous actions have completed.Example:
asyncActions.type(firstField, "value1") .click(submitButton) .sync();- Returns:
- this
AsyncElementActionsinstance for fluent chaining - See Also:
-