Element Interactions Overview
DriverActions provides a unified API entry point to specialized interaction modules.
Available Interaction Types
Ellithium provides specialized interaction modules for different types of actions:
DriverActions actions = new DriverActions(driver);
// Access modules
actions.elements(); // Element interactions (click, type, text, attributes)
actions.JSActions(); // JavaScript operations
actions.alerts(); // Alert handling
actions.frames(); // Frame switching and waits
actions.windows(); // Window management
actions.waits(); // Wait utilities
actions.select(); // Native <select> dropdowns
actions.navigation(); // Browser navigation
actions.mouse(); // Mouse operations
// Mobile-specific
actions.androidActions(); // Android gestures & key events
actions.iosActions(); // iOS gestures
Detailed Documentation
Each interaction type has its own detailed documentation:
- Element Actions - Core element interactions
- JavaScript Actions - Browser JavaScript execution
- Alert Actions - Dialog handling
- Frame Actions - Working with iframes
- Mouse Actions - Advanced mouse operations
- Navigation Actions - Page navigation
- Wait Actions - Synchronization utilities
- Window Actions - Window management
- Key Press Actions - Android key events
- Select Actions - Dropdown handling
- Screen Recorder Actions - Video recording
- Android Actions - Android gestures
- iOS Actions - iOS gestures
Element Interactions
The most commonly used module for working with web elements:
// Basic element interactions
actions.elements().clickOnElement(By.id("submitButton"));
actions.elements().sendData(By.id("username"), "testuser");
// Text
String text = actions.elements().getText(By.id("message"));
// Attributes
String href = actions.elements().getAttributeValue(By.cssSelector("a"), "href");
// Collections
List<String> titles = actions.elements().getTextFromMultipleElements(By.cssSelector(".title"));
JavaScript Operations
For situations where standard WebDriver methods aren't sufficient:
// JavaScript operations
actions.JSActions().javascriptClick(By.id("submitButton"));
actions.JSActions().scrollToElement(By.id("elementAtBottom"));
actions.JSActions().scrollByOffset(0, 500);
actions.JSActions().setElementValueUsingJS(By.id("username"), "testuser");
actions.JSActions().uploadFileUsingJS(By.id("fileInput"), "C:/path/to/file.txt");
Alert Handling
// Alert operations
actions.alerts().accept(10, 200); // Wait up to 10 seconds, polling every 200ms
actions.alerts().dismiss();
String alertText = actions.alerts().getText();
actions.alerts().sendData("Alert input text");
Window Management
actions.windows().switchToNewWindow("Window Title");
actions.windows().maximizeWindow();
actions.windows().closeCurrentWindow();
actions.windows().switchToPopupWindow("Popup Title");
actions.windows().setWindowSize(1024, 768);
actions.windows().switchToWindowByIndex(1);
Wait Operations
In addition to element-specific waits, Ellithium provides general wait operations:
actions.waits().waitForTitleContains("Home Page");
actions.waits().waitForUrlContains("dashboard");
actions.waits().waitForNumberOfWindowsToBe(2);
actions.waits().waitForElementAttributeToBe(By.id("status"), "class", "active");
Timeout Handling
Most methods offer overloads with default timeout/polling and explicit control:
// Default timeout
actions.elements().sendData(By.id("username"), "testuser");
// Custom timeout in seconds
actions.elements().sendData(By.id("username"), "testuser", 10);
// Custom timeout and polling
actions.elements().sendData(By.id("username"), "testuser", 10, 200);
Navigation Operations
actions.navigation().navigateToUrl("https://example.com");
actions.navigation().refreshPage();
actions.navigation().navigateBack();
actions.navigation().navigateForward();
Mobile Modules
// Android gestures
actions.androidActions().swipeGesture(100, 1200, 900, 1200, 300);
// iOS gestures
actions.iosActions().tap(120f, 220f);