Selenium Chrome Driver provides WebDriver implementation for Google Chrome with Chrome DevTools Protocol support, network conditions simulation, permissions management, media casting capabilities, and Chrome-specific service configuration.
npx @tessl/cli install tessl/maven-org-seleniumhq-selenium--selenium-chromium-driver@4.33.0Selenium Chromium Driver is a specialized WebDriver implementation that provides a unified interface for controlling Chromium-based browsers (Chrome, Edge, Opera) in automated testing and web scraping scenarios. It extends Selenium's core remote WebDriver functionality with Chromium-specific capabilities including Chrome DevTools Protocol (CDP) support, network conditions manipulation, permissions management, application launching, and media casting features.
org.seleniumhq.selenium:selenium-chromium-driver:4.33.0pom.xml:<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chromium-driver</artifactId>
<version>4.33.0</version>
</dependency>import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.chrome.ChromeDriverService;
import org.openqa.selenium.chrome.ChromeDriverInfo;
import org.openqa.selenium.chromium.ChromiumNetworkConditions;
import org.openqa.selenium.chromium.HasCdp;
import org.openqa.selenium.chromium.HasCasting;
import org.openqa.selenium.chromium.HasNetworkConditions;
import org.openqa.selenium.chromium.HasPermissions;
import org.openqa.selenium.chromium.HasLaunchApp;import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.chrome.ChromeDriverService;
// Basic Chrome driver usage with default service and options
ChromeDriver driver = new ChromeDriver();
// Configure Chrome options
ChromeOptions options = new ChromeOptions();
options.addArguments("--headless", "--no-sandbox");
options.setBinary("/path/to/chrome");
// Create driver with options
ChromeDriver driverWithOptions = new ChromeDriver(options);
// Using custom service
ChromeDriverService service = ChromeDriverService.createDefaultService();
ChromeDriver driverWithService = new ChromeDriver(service, options);
// Use standard WebDriver methods
driver.get("https://example.com");
String title = driver.getTitle();
// Use Chrome-specific features (available through interfaces)
if (driver instanceof HasPermissions) {
((HasPermissions) driver).setPermission("camera", "granted");
}
if (driver instanceof HasLaunchApp) {
((HasLaunchApp) driver).launchApp("chrome-app-id");
}
// Clean up
driver.quit();The Selenium Chromium Driver is built around several key components:
Chrome-specific WebDriver implementation providing seamless integration with Google Chrome browser.
public class ChromeDriver extends ChromiumDriver {
public ChromeDriver();
public ChromeDriver(ChromeDriverService service);
public ChromeDriver(ChromeOptions options);
public ChromeDriver(ChromeDriverService service, ChromeOptions options);
public ChromeDriver(ChromeDriverService service, ChromeOptions options, ClientConfig clientConfig);
public static RemoteWebDriverBuilder builder();
}
public class ChromeOptions extends ChromiumOptions<ChromeOptions> {
public static final String CAPABILITY = "goog:chromeOptions";
public static final String LOGGING_PREFS = "goog:loggingPrefs";
public ChromeOptions();
public ChromeOptions merge(Capabilities extraCapabilities);
}
public class ChromeDriverService extends DriverService {
public static final String CHROME_DRIVER_NAME = "chromedriver";
public static final String CHROME_DRIVER_EXE_PROPERTY = "webdriver.chrome.driver";
public static ChromeDriverService createDefaultService();
public String getDriverName();
public String getDriverProperty();
public Capabilities getDefaultDriverOptions();
}Standard WebDriver operations with Chromium-specific enhancements including script pinning, authentication handling, and enhanced element interaction.
public class ChromiumDriver extends RemoteWebDriver {
public ScriptKey pin(String script);
public Set<ScriptKey> getPinnedScripts();
public void unpin(ScriptKey key);
public Object executeScript(ScriptKey key, Object... args);
public <X> void onLogEvent(EventType<X> kind);
public void register(Predicate<URI> whenThisMatches, Supplier<Credentials> useTheseCredentials);
}Comprehensive browser configuration including binary paths, command line arguments, extensions, and Android-specific settings.
public abstract class ChromiumOptions<T extends ChromiumOptions<?>> {
public T setBinary(String path);
public T addArguments(String... arguments);
public T addExtensions(File... paths);
public T addEncodedExtensions(String... encoded);
public T setExperimentalOption(String name, Object value);
public T enableBiDi();
}Execute Chrome DevTools Protocol commands for advanced browser control and debugging capabilities.
public interface HasCdp {
Map<String, Object> executeCdpCommand(String commandName, Map<String, Object> parameters);
}Simulate various network conditions for testing applications under different connectivity scenarios.
public interface HasNetworkConditions {
ChromiumNetworkConditions getNetworkConditions();
void setNetworkConditions(ChromiumNetworkConditions networkConditions);
void deleteNetworkConditions();
}
public class ChromiumNetworkConditions {
public boolean getOffline();
public void setOffline(boolean offline);
public Duration getLatency();
public void setLatency(Duration latency);
public int getDownloadThroughput();
public void setDownloadThroughput(int downloadThroughput);
public int getUploadThroughput();
public void setUploadThroughput(int uploadThroughput);
}Cast media content to available devices using Chrome's casting capabilities.
public interface HasCasting {
List<Map<String, String>> getCastSinks();
void selectCastSink(String deviceName);
void startDesktopMirroring(String deviceName);
void startTabMirroring(String deviceName);
String getCastIssueMessage();
void stopCasting(String deviceName);
}Manage browser permissions for camera, microphone, geolocation, and other web APIs.
public interface HasPermissions {
void setPermission(String name, String value);
}Launch Chromium applications and manage app lifecycles.
public interface HasLaunchApp {
void launchApp(String id);
}Configure and manage ChromeDriverService for advanced driver lifecycle control.
public class ChromeDriverService extends DriverService {
public static final String CHROME_DRIVER_NAME = "chromedriver";
public static final String CHROME_DRIVER_EXE_PROPERTY = "webdriver.chrome.driver";
public static final String CHROME_DRIVER_LOG_PROPERTY = "webdriver.chrome.logfile";
public static final String CHROME_DRIVER_LOG_LEVEL_PROPERTY = "webdriver.chrome.loglevel";
public static final String CHROME_DRIVER_VERBOSE_LOG_PROPERTY = "webdriver.chrome.verboseLogging";
public static final String CHROME_DRIVER_SILENT_OUTPUT_PROPERTY = "webdriver.chrome.silentOutput";
public static final String CHROME_DRIVER_APPEND_LOG_PROPERTY = "webdriver.chrome.appendLog";
public static final String CHROME_DRIVER_ALLOWED_IPS_PROPERTY = "webdriver.chrome.withAllowedIps";
public static final String CHROME_DRIVER_DISABLE_BUILD_CHECK = "webdriver.chrome.disableBuildCheck";
public static final String CHROME_DRIVER_READABLE_TIMESTAMP = "webdriver.chrome.readableTimestamp";
public static ChromeDriverService createDefaultService();
public String getDriverName();
public String getDriverProperty();
public Capabilities getDefaultDriverOptions();
}
public static class Builder extends DriverService.Builder<ChromeDriverService, ChromeDriverService.Builder> {
public Builder withAppendLog(boolean appendLog);
public Builder withBuildCheckDisabled(boolean noBuildCheck);
public Builder withLogLevel(ChromiumDriverLogLevel logLevel);
public Builder withSilent(boolean silent);
public Builder withVerbose(boolean verbose);
public Builder withAllowedListIps(String allowedListIps);
public Builder withReadableTimestamp(Boolean readableTimestamp);
}// Predicate for checking if browser is Chromium-based
public static final Predicate<String> IS_CHROMIUM_BROWSER;
// Log level enumeration
public enum ChromiumDriverLogLevel {
ALL, INFO, DEBUG, WARNING, SEVERE, OFF;
public static ChromiumDriverLogLevel fromString(String text);
public static ChromiumDriverLogLevel fromLevel(Level level);
}
// Driver information base class
public abstract class ChromiumDriverInfo implements WebDriverInfo {
public int getMaximumSimultaneousSessions();
}
// Command executor for Chromium-specific commands
public class ChromiumDriverCommandExecutor extends DriverCommandExecutor {
public ChromiumDriverCommandExecutor(DriverService service, Map<String, CommandInfo> extraCommands);
public ChromiumDriverCommandExecutor(DriverService service, Map<String, CommandInfo> extraCommands, ClientConfig clientConfig);
}The Chromium Driver may throw the following exceptions:
WebDriverException - For general WebDriver errorsSessionNotCreatedException - When browser session cannot be createdJavascriptException - For JavaScript execution errorsConnectionFailedException - When DevTools connection failsBiDiException - For BiDi protocol errorsCommon error scenarios include missing browser binaries, invalid extension files, network connection issues, and unsupported DevTools commands.