Package org.openqa.selenium.chromium
Class ChromiumDriver
java.lang.Object
org.openqa.selenium.remote.RemoteWebDriver
org.openqa.selenium.chromium.ChromiumDriver
- All Implemented Interfaces:
HasBiDi
,HasCasting
,HasCdp
,HasLaunchApp
,HasNetworkConditions
,HasPermissions
,HasDevTools
,HasFederatedCredentialManagement
,HasAuthentication
,HasCapabilities
,HasDownloads
,LocationContext
,WebStorage
,Interactive
,JavascriptExecutor
,HasLogEvents
,NetworkConnection
,PrintsPage
,SearchContext
,TakesScreenshot
,HasVirtualAuthenticator
,WebDriver
- Direct Known Subclasses:
ChromeDriver
,EdgeDriver
public class ChromiumDriver
extends RemoteWebDriver
implements HasAuthentication, HasBiDi, HasCasting, HasCdp, HasDevTools, HasLaunchApp, HasLogEvents, HasNetworkConditions, HasPermissions, LocationContext, NetworkConnection, WebStorage
A
WebDriver
implementation that controls a Chromium browser running on the local machine.
It is used as the base class for Chromium-based browser drivers (Chrome, Edge).-
Nested Class Summary
Nested classes/interfaces inherited from class org.openqa.selenium.remote.RemoteWebDriver
RemoteWebDriver.RemoteTargetLocator, RemoteWebDriver.RemoteWebDriverOptions, RemoteWebDriver.When
Nested classes/interfaces inherited from interface org.openqa.selenium.mobile.NetworkConnection
NetworkConnection.ConnectionType
Nested classes/interfaces inherited from interface org.openqa.selenium.WebDriver
WebDriver.Navigation, WebDriver.Options, WebDriver.TargetLocator, WebDriver.Timeouts, WebDriver.Window
-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
ChromiumDriver
(CommandExecutor commandExecutor, Capabilities capabilities, String capabilityKey) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Resets the network conditions to the default settings.executeCdpCommand
(String commandName, Map<String, Object> parameters) Execute a Chrome DevTools Protocol command and get returned result.executeScript
(ScriptKey key, Object... args) Calls a script by theScriptKey
returned byJavascriptExecutor.pin(String)
.Returns the list of cast sinks (Cast devices) available to the Chrome media router.Deprecated.Gets map of network conditions.Deprecated.Deprecated.void
location()
Deprecated.<X> void
onLogEvent
(EventType<X> kind) Commonly used scripts may be "pinned" to the WebDriver session, allowing them to be called efficiently by their handle rather than sending the entire script across the wire for every call.void
quit()
Quits this driver, closing every associated window.void
register
(Predicate<URI> whenThisMatches, Supplier<Credentials> useTheseCredentials) Registers a check for whether a set ofCredentials
should be used for a particular site, identified by its URI.void
selectCastSink
(String deviceName) Selects a cast sink (Cast device) as the recipient of media router intents (connect or play).void
setFileDetector
(FileDetector detector) Set the file detector to be used when sending keyboard input.void
setLocation
(Location location) Deprecated.void
setNetworkConditions
(ChromiumNetworkConditions networkConditions) Set network limitationsDeprecated.void
setPermission
(String name, String value) void
startDesktopMirroring
(String deviceName) Initiates desktop mirroring for the current browser tab on the specified device.void
startTabMirroring
(String deviceName) Initiates tab mirroring for the current browser tab on the specified device.void
stopCasting
(String deviceName) Stops casting from media router to the specified device, if connected.void
Deletes the reference to a script that has previously been pinned.Methods inherited from class org.openqa.selenium.remote.RemoteWebDriver
addVirtualAuthenticator, builder, close, deleteDownloadableFiles, downloadFile, execute, execute, execute, executeAsyncScript, executeScript, findElement, findElements, findElements, get, getCommandExecutor, getCurrentUrl, getDownloadableFiles, getElementConverter, getErrorHandler, getExecuteMethod, getFederatedCredentialManagementDialog, getFileDetector, getPageSource, getScreenshotAs, getSessionId, getTitle, getWindowHandle, getWindowHandles, log, manage, navigate, network, perform, print, removeVirtualAuthenticator, resetCooldown, resetInputState, script, setCommandExecutor, setDelayEnabled, setElementConverter, setErrorHandler, setFoundBy, setLogLevel, setSessionId, startSession, switchTo, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.openqa.selenium.HasAuthentication
register
Methods inherited from interface org.openqa.selenium.devtools.HasDevTools
getDevTools
Methods inherited from interface org.openqa.selenium.HasDownloads
requireDownloadsEnabled
-
Field Details
-
IS_CHROMIUM_BROWSER
-
casting
-
cdp
-
-
Constructor Details
-
ChromiumDriver
protected ChromiumDriver(CommandExecutor commandExecutor, Capabilities capabilities, String capabilityKey)
-
-
Method Details
-
getCapabilities
- Specified by:
getCapabilities
in interfaceHasCapabilities
- Overrides:
getCapabilities
in classRemoteWebDriver
- Returns:
- The capabilities of the current driver.
-
pin
Description copied from interface:JavascriptExecutor
Commonly used scripts may be "pinned" to the WebDriver session, allowing them to be called efficiently by their handle rather than sending the entire script across the wire for every call.The default implementation of this adheres to the API's expectations but is inefficient.
- Specified by:
pin
in interfaceJavascriptExecutor
- Parameters:
script
- The Javascript to execute.- Returns:
- A handle which may later be used in
JavascriptExecutor.executeScript(ScriptKey, Object...)
- See Also:
-
getPinnedScripts
- Specified by:
getPinnedScripts
in interfaceJavascriptExecutor
- Returns:
- The
ScriptKey
s of all currently pinned scripts.
-
unpin
Description copied from interface:JavascriptExecutor
Deletes the reference to a script that has previously been pinned. Subsequent calls toJavascriptExecutor.executeScript(ScriptKey, Object...)
will fail for the givenkey
.- Specified by:
unpin
in interfaceJavascriptExecutor
-
executeScript
Description copied from interface:JavascriptExecutor
Calls a script by theScriptKey
returned byJavascriptExecutor.pin(String)
. This can be thought of as inlining the pinned script and simply callingJavascriptExecutor.executeScript(String, Object...)
.- Specified by:
executeScript
in interfaceJavascriptExecutor
- See Also:
-
setFileDetector
Description copied from class:RemoteWebDriver
Set the file detector to be used when sending keyboard input. By default, this is set to a file detector that does nothing.- Overrides:
setFileDetector
in classRemoteWebDriver
- Parameters:
detector
- The detector to use. Must not be null.- See Also:
-
onLogEvent
- Specified by:
onLogEvent
in interfaceHasLogEvents
-
register
Description copied from interface:HasAuthentication
Registers a check for whether a set ofCredentials
should be used for a particular site, identified by its URI. If called multiple times, the credentials will be checked in the order they've been added and the first one to match will be used.- Specified by:
register
in interfaceHasAuthentication
-
getLocalStorage
Deprecated.- Specified by:
getLocalStorage
in interfaceWebStorage
-
getSessionStorage
Deprecated.- Specified by:
getSessionStorage
in interfaceWebStorage
-
location
Deprecated.Description copied from interface:LocationContext
Gets the physical location of the browser.- Specified by:
location
in interfaceLocationContext
- Returns:
- A
Location
containing the location information. Returns null if the location is not available
-
setLocation
Deprecated.Description copied from interface:LocationContext
Sets the physical location.- Specified by:
setLocation
in interfaceLocationContext
- Parameters:
location
- ALocation
containing the new location information
-
getNetworkConnection
Deprecated.Description copied from interface:NetworkConnection
Query the driver for the Airplane Mode setting state- Specified by:
getNetworkConnection
in interfaceNetworkConnection
- Returns:
NetworkConnection.ConnectionType
indicating if the device is in Airplane Mode
-
setNetworkConnection
@Deprecated public NetworkConnection.ConnectionType setNetworkConnection(NetworkConnection.ConnectionType type) Deprecated.Description copied from interface:NetworkConnection
Set the Connection type Not all connection type combinations are valid for an individual type of device and the remote endpoint will make a best effort to set the type as requested- Specified by:
setNetworkConnection
in interfaceNetworkConnection
- Parameters:
type
- ConnectionType of what the network connection should be- Returns:
NetworkConnection.ConnectionType
of what the device's network connection is
-
launchApp
- Specified by:
launchApp
in interfaceHasLaunchApp
- Parameters:
id
- which Chromium app to launch.
-
executeCdpCommand
Description copied from interface:HasCdp
Execute a Chrome DevTools Protocol command and get returned result. The command and command args should follow chrome devtools protocol domains/commands.It is strongly encouraged to use
DevTools
API instead of this- Specified by:
executeCdpCommand
in interfaceHasCdp
- Parameters:
commandName
- the command to execute with Chrome Dev Tools.parameters
- any information needed to execute the Dev Tools command.- Returns:
- the name and value of the response.
-
maybeGetDevTools
- Specified by:
maybeGetDevTools
in interfaceHasDevTools
-
maybeGetBiDi
- Specified by:
maybeGetBiDi
in interfaceHasBiDi
-
getCastSinks
Description copied from interface:HasCasting
Returns the list of cast sinks (Cast devices) available to the Chrome media router.- Specified by:
getCastSinks
in interfaceHasCasting
- Returns:
- array of ID / Name pairs of available cast sink targets
-
getCastIssueMessage
- Specified by:
getCastIssueMessage
in interfaceHasCasting
- Returns:
- an error message if there is any issue in a Cast session.
-
selectCastSink
Description copied from interface:HasCasting
Selects a cast sink (Cast device) as the recipient of media router intents (connect or play).- Specified by:
selectCastSink
in interfaceHasCasting
- Parameters:
deviceName
- name of the target device.
-
startDesktopMirroring
Description copied from interface:HasCasting
Initiates desktop mirroring for the current browser tab on the specified device.- Specified by:
startDesktopMirroring
in interfaceHasCasting
- Parameters:
deviceName
- name of the target device.
-
startTabMirroring
Description copied from interface:HasCasting
Initiates tab mirroring for the current browser tab on the specified device.- Specified by:
startTabMirroring
in interfaceHasCasting
- Parameters:
deviceName
- name of the target device.
-
stopCasting
Description copied from interface:HasCasting
Stops casting from media router to the specified device, if connected.- Specified by:
stopCasting
in interfaceHasCasting
- Parameters:
deviceName
- name of the target device.
-
setPermission
- Specified by:
setPermission
in interfaceHasPermissions
- Parameters:
name
- what item to set the permission on.value
- what to set the permission to.
-
getNetworkConditions
Description copied from interface:HasNetworkConditions
Gets map of network conditions. These have to be set before they can be retrieved.- Specified by:
getNetworkConditions
in interfaceHasNetworkConditions
- Returns:
- the current network condition values.
-
setNetworkConditions
Description copied from interface:HasNetworkConditions
Set network limitations- Specified by:
setNetworkConditions
in interfaceHasNetworkConditions
- Parameters:
networkConditions
- object containing valid network condition settings.
-
deleteNetworkConditions
public void deleteNetworkConditions()Description copied from interface:HasNetworkConditions
Resets the network conditions to the default settings.- Specified by:
deleteNetworkConditions
in interfaceHasNetworkConditions
-
quit
public void quit()Description copied from interface:WebDriver
Quits this driver, closing every associated window.- Specified by:
quit
in interfaceWebDriver
- Overrides:
quit
in classRemoteWebDriver
-