CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-org-seleniumhq-selenium--selenium-remote-driver

WebDriver remote communication library that provides the core infrastructure for browser automation across different platforms and programming languages.

Pending
Overview
Eval results
Files

webdriver-operations.mddocs/

WebDriver Operations

Core WebDriver implementation providing the primary interface for remote browser control, including navigation, element interaction, JavaScript execution, and session management.

Capabilities

RemoteWebDriver

The main WebDriver implementation for controlling remote browser instances.

/**
 * Remote WebDriver implementation that communicates with browser instances via HTTP
 */
@Augmentable
public class RemoteWebDriver implements WebDriver, HasCapabilities, TakesScreenshot, 
    JavascriptExecutor, PrintsPage, Interactive, HasDownloads, HasVirtualAuthenticator, 
    HasFederatedCredentialManagement {
    
    // Constructors
    public RemoteWebDriver();
    public RemoteWebDriver(Capabilities capabilities);
    public RemoteWebDriver(Capabilities capabilities, boolean enableTracing);
    public RemoteWebDriver(URL remoteAddress, Capabilities capabilities);
    public RemoteWebDriver(URL remoteAddress, Capabilities capabilities, boolean enableTracing);
    public RemoteWebDriver(CommandExecutor executor, Capabilities capabilities);
    
    // Navigation
    public void get(String url);
    public String getCurrentUrl();
    public String getTitle();
    public String getPageSource();
    public void close();
    public void quit();
    
    // Window management
    public Set<String> getWindowHandles();
    public String getWindowHandle();
    public TargetLocator switchTo();
    public Navigation navigate();
    public Options manage();
    
    // Element operations
    public WebElement findElement(By locator);
    public List<WebElement> findElements(By locator);
    
    // JavaScript execution
    public Object executeScript(String script, Object... args);
    public Object executeAsyncScript(String script, Object... args);
    
    // Screenshots
    public <X> X getScreenshotAs(OutputType<X> outputType) throws WebDriverException;
    
    // PDF generation
    public Pdf print(PrintOptions printOptions);
    
    // Session information
    public Capabilities getCapabilities();
    public SessionId getSessionId();
    public void setLogLevel(Level level);
    
    // File handling
    public FileDetector getFileDetector();
    public void setFileDetector(FileDetector detector);
    
    // Downloads management
    public List<String> getDownloadableFiles();
    public void downloadFile(String fileName, Path targetLocation) throws IOException;
    public void deleteDownloadableFiles();
    
    // Script management
    public Script script();
    
    // Network management
    public Network network();
    
    // Virtual Authenticator support
    public VirtualAuthenticator addVirtualAuthenticator(VirtualAuthenticatorOptions options);
    public void removeVirtualAuthenticator(VirtualAuthenticator authenticator);
    
    // FedCM support
    public FederatedCredentialManagementDialog getFederatedCredentialManagementDialog();
    public void setDelayEnabled(boolean enabled);
    public void resetCooldown();
    
    // Builder pattern (Beta)
    public static RemoteWebDriverBuilder builder();
}

Usage Examples:

import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import java.net.URL;

// Basic setup
DesiredCapabilities caps = new DesiredCapabilities();
caps.setBrowserName("chrome");
RemoteWebDriver driver = new RemoteWebDriver(
    new URL("http://localhost:4444/wd/hub"), caps);

// Navigation
driver.get("https://example.com");
String title = driver.getTitle();
String currentUrl = driver.getCurrentUrl();

// Element interaction
WebElement element = driver.findElement(By.id("submit-button"));
element.click();

// JavaScript execution
Object result = driver.executeScript("return document.title;");
Long count = (Long) driver.executeScript("return arguments[0].length;", "hello");

// Window management
String originalWindow = driver.getWindowHandle();
Set<String> allWindows = driver.getWindowHandles();

// Cleanup
driver.quit();

RemoteWebDriverBuilder

Builder pattern for creating RemoteWebDriver instances with flexible configuration (Beta feature).

/**
 * Builder for creating RemoteWebDriver instances with flexible configuration
 */
public class RemoteWebDriverBuilder {
    public RemoteWebDriverBuilder addAlternative(Capabilities capabilities);
    public RemoteWebDriverBuilder addMetadata(String key, Object value);
    public RemoteWebDriverBuilder setCapability(String key, Object value);
    public RemoteWebDriverBuilder address(URI uri);
    public RemoteWebDriverBuilder withDriverService(DriverService service);
    public RemoteWebDriver build();
}

Usage Examples:

import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import java.net.URI;

// Using builder pattern
RemoteWebDriver driver = RemoteWebDriver.builder()
    .address(URI.create("http://localhost:4444/wd/hub"))
    .addAlternative(new ChromeOptions())
    .addMetadata("test-name", "my-test")
    .setCapability("browserVersion", "latest")
    .build();

RemoteWebElement

WebElement implementation for remote elements that provides all standard element interaction capabilities.

/**
 * WebElement implementation for elements controlled through remote WebDriver
 */
public class RemoteWebElement implements WebElement, TakesScreenshot, 
    Locatable, WrapsDriver {
    
    // Element actions
    public void click();
    public void submit();
    public void sendKeys(CharSequence... keysToSend);
    public void clear();
    
    // Element properties
    public String getTagName();
    public String getDomProperty(String name);
    public String getDomAttribute(String name);
    public String getAttribute(String name);
    public String getAriaRole();
    public String getAccessibleName();
    public String getText();
    public String getCssValue(String propertyName);
    
    // Element state
    public boolean isSelected();
    public boolean isEnabled();
    public boolean isDisplayed();
    
    // Element location and size
    public Point getLocation();
    public Dimension getSize();
    public Rectangle getRect();
    
    // Element search
    public WebElement findElement(By locator);
    public List<WebElement> findElements(By locator);
    public SearchContext getShadowRoot();
    
    // Screenshots (Beta)
    public <X> X getScreenshotAs(OutputType<X> outputType) throws WebDriverException;
    
    // Internal methods
    public String getId();
    public void setId(String id);
    public void setParent(RemoteWebDriver parent);
    public void setFileDetector(FileDetector detector);
    public Map<String, Object> toJson();
}

Usage Examples:

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.RemoteWebElement;

// Element interaction
WebElement input = driver.findElement(By.name("username"));
input.sendKeys("testuser");
input.clear();

// Element properties
String tagName = input.getTagName();
String value = input.getAttribute("value");
String cssColor = input.getCssValue("color");
boolean isEnabled = input.isEnabled();

// Element location
Point location = input.getLocation();
Dimension size = input.getSize();
Rectangle rect = input.getRect();

// Nested element search
WebElement form = driver.findElement(By.id("login-form"));
WebElement submitButton = form.findElement(By.tagName("button"));

// Shadow DOM access
SearchContext shadowRoot = element.getShadowRoot();
WebElement shadowElement = shadowRoot.findElement(By.cssSelector("input"));

File Detection

File detection system for handling file uploads in remote environments.

/**
 * Interface for detecting local files during remote operations
 */
public interface FileDetector {
    File getLocalFile(CharSequence... keys);
}

/**
 * File detector that identifies local files for upload
 */
public class LocalFileDetector implements FileDetector {
    public LocalFileDetector();
    public File getLocalFile(CharSequence... keys);
}

/**
 * No-op file detector (default behavior)
 */
public class UselessFileDetector implements FileDetector {
    public UselessFileDetector();
    public File getLocalFile(CharSequence... keys);
}

Usage Examples:

import org.openqa.selenium.remote.LocalFileDetector;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;

// Enable file detection for uploads
driver.setFileDetector(new LocalFileDetector());

// Upload a file
WebElement fileInput = driver.findElement(By.type("file"));
fileInput.sendKeys("/path/to/local/file.txt");

Script Management

Script management functionality for pinning and executing JavaScript code efficiently.

/**
 * Interface for managing pinned scripts
 */
public interface Script {
    ScriptKey pin(String script);
    void unpin(ScriptKey key);
    Set<ScriptKey> getPinnedScripts();
    Object executeScript(ScriptKey key, Object... args);
}

Usage Examples:

// Pin a frequently used script
Script scriptManager = driver.script();
ScriptKey key = scriptManager.pin("return document.readyState;");

// Execute pinned script multiple times efficiently
Object state1 = scriptManager.executeScript(key);
Object state2 = scriptManager.executeScript(key);

// Clean up
scriptManager.unpin(key);

Network Management

Network-level operations including authentication handlers.

/**
 * Interface for network-related operations
 */
public interface Network {
    void addAuthenticationHandler(Predicate<URI> when, Supplier<Credentials> authentication);
    void clearAuthenticationHandlers();
}

Install with Tessl CLI

npx tessl i tessl/maven-org-seleniumhq-selenium--selenium-remote-driver

docs

capabilities-management.md

command-execution.md

distributed-tracing.md

driver-services.md

http-communication.md

index.md

webdriver-operations.md

tile.json