WebDriver remote communication library that provides the core infrastructure for browser automation across different platforms and programming languages.
npx @tessl/cli install tessl/maven-org-seleniumhq-selenium--selenium-remote-driver@4.33.0Selenium Remote Driver is a foundational Java library that implements the W3C WebDriver wire protocol for remote browser automation. It provides comprehensive infrastructure for session management, command execution, HTTP transport, error handling, and capability negotiation across different WebDriver dialects. The library serves as the communication layer between WebDriver client code and remote browser instances, enabling scalable cross-browser testing and distributed web application automation.
org.seleniumhq.selenium:selenium-remote-driver:4.33.0pom.xml:<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-remote-driver</artifactId>
<version>4.33.0</version>
</dependency>import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.HttpCommandExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.Platform;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import java.util.UUID;
import java.util.List;
import java.util.Map;import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import java.net.URL;
// Create capabilities for the browser
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setBrowserName("chrome");
capabilities.setPlatform(Platform.ANY);
// Connect to a remote WebDriver instance
WebDriver driver = new RemoteWebDriver(
new URL("http://selenium-grid:4444/wd/hub"),
capabilities
);
// Use the driver
driver.get("https://example.com");
String title = driver.getTitle();
driver.quit();Selenium Remote Driver is built around several key architectural components:
CommandExecutor interface with HTTP-based implementation for sending WebDriver commands over the wireCore WebDriver implementation providing the primary interface for remote browser control, including navigation, element interaction, JavaScript execution, and session management.
@Augmentable
public class RemoteWebDriver implements WebDriver, JavascriptExecutor, HasCapabilities,
HasDownloads, HasFederatedCredentialManagement, HasVirtualAuthenticator, Interactive,
PrintsPage, TakesScreenshot {
public RemoteWebDriver(URL remoteAddress, Capabilities capabilities);
public RemoteWebDriver(CommandExecutor executor, Capabilities capabilities);
// Navigation
public void get(String url);
public String getCurrentUrl();
public String getTitle();
// 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);
// Session management
public Capabilities getCapabilities();
public SessionId getSessionId();
public void quit();
}HTTP-based command execution framework that handles the communication protocol between WebDriver clients and remote browser instances.
public interface CommandExecutor {
Response execute(Command command) throws IOException;
}
public class HttpCommandExecutor implements CommandExecutor, NeedsLocalLogs {
public HttpCommandExecutor(URL addressOfRemoteServer);
public HttpCommandExecutor(ClientConfig config);
public Response execute(Command command) throws IOException;
}
public class Command {
public Command(SessionId sessionId, String name, Map<String, ?> parameters);
public SessionId getSessionId();
public String getName();
public Map<String, ?> getParameters();
}Comprehensive HTTP client infrastructure with support for WebSocket connections, request/response handling, routing, and connection management.
public interface HttpClient {
HttpResponse execute(HttpRequest req);
CompletableFuture<HttpResponse> executeAsync(HttpRequest req);
WebSocket openSocket(HttpRequest request, WebSocket.Listener listener);
void close();
}
public class ClientConfig {
public static ClientConfig defaultConfig();
public ClientConfig baseUrl(URL baseUrl);
public ClientConfig withFilter(Filter filter);
public ClientConfig readTimeout(Duration timeout);
}
public class HttpRequest {
public HttpRequest(HttpMethod method, String uri);
public HttpMethod getMethod();
public String getUri();
}Management of native driver executables including automatic discovery, lifecycle control, and process communication.
public abstract class DriverService {
public abstract String getExecutable();
public abstract URL getUrl();
public void start();
public void stop();
public boolean isRunning();
public void sendOutputTo(OutputStream outputStream);
}
public class DriverCommandExecutor implements CommandExecutor {
public DriverCommandExecutor(DriverService service);
public Response execute(Command command);
}Browser capability specification and negotiation system for defining browser requirements and configuration options.
public class DesiredCapabilities implements MutableCapabilities {
public DesiredCapabilities();
public DesiredCapabilities(String browser, String version, Platform platform);
public void setBrowserName(String browserName);
public void setVersion(String version);
public void setPlatform(Platform platform);
public void setAcceptInsecureCerts(boolean acceptInsecureCerts);
}
public interface CapabilityType {
String BROWSER_NAME = "browserName";
String PLATFORM_NAME = "platformName";
String BROWSER_VERSION = "browserVersion";
String ACCEPT_INSECURE_CERTS = "acceptInsecureCerts";
}OpenTelemetry-based distributed tracing support for observability in distributed testing environments.
public interface Tracer {
TraceContext getCurrentContext();
Propagator getPropagator();
AttributeMap createAttributeMap();
}
public interface Span {
Span setName(String name);
Span addTag(String key, String value);
Span addEvent(String name);
void close();
}
public class TracedCommandExecutor implements CommandExecutor {
public TracedCommandExecutor(CommandExecutor executor, Tracer tracer);
public Response execute(Command command);
}public class SessionId {
public SessionId(String opaqueKey);
public SessionId(UUID uuid);
public String toString();
}
public class Response {
public Response();
public Response(SessionId sessionId);
public String getState();
public void setState(String state);
public Object getValue();
public void setValue(Object value);
}
public enum HttpMethod {
DELETE, GET, POST, PUT
}
public interface Browser {
Browser CHROME = create("chrome");
Browser EDGE = create("msedge");
Browser FIREFOX = create("firefox");
Browser SAFARI = create("safari");
String browserName();
boolean is(String browserName);
}