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,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, 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.WhenNested classes/interfaces inherited from interface org.openqa.selenium.WebDriver
WebDriver.Navigation, WebDriver.Options, WebDriver.TargetLocator, WebDriver.Timeouts, WebDriver.Window -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedChromiumDriver(CommandExecutor commandExecutor, Capabilities capabilities, String capabilityKey) -
Method Summary
Modifier and TypeMethodDescriptionvoidResets 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 theScriptKeyreturned byJavascriptExecutor.pin(String).Returns the list of cast sinks (Cast devices) available to the Chrome media router.Deprecated.Gets map of network conditions.Deprecated.voidlocation()Deprecated.<X> voidonLogEvent(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.voidquit()Quits this driver, closing every associated window.voidregister(Predicate<URI> whenThisMatches, Supplier<Credentials> useTheseCredentials) Registers a check for whether a set ofCredentialsshould be used for a particular site, identified by its URI.voidselectCastSink(String deviceName) Selects a cast sink (Cast device) as the recipient of media router intents (connect or play).voidsetFileDetector(FileDetector detector) Set the file detector to be used when sending keyboard input.voidsetLocation(Location location) Deprecated.voidsetNetworkConditions(ChromiumNetworkConditions networkConditions) Set network limitationsvoidsetPermission(String name, String value) voidstartDesktopMirroring(String deviceName) Initiates desktop mirroring for the current browser tab on the specified device.voidstartTabMirroring(String deviceName) Initiates tab mirroring for the current browser tab on the specified device.voidstopCasting(String deviceName) Stops casting from media router to the specified device, if connected.voidDeletes 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, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.openqa.selenium.HasAuthentication
registerMethods inherited from interface org.openqa.selenium.devtools.HasDevTools
getDevToolsMethods 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:
getCapabilitiesin interfaceHasCapabilities- Overrides:
getCapabilitiesin classRemoteWebDriver- Returns:
- The capabilities of the current driver.
-
pin
Description copied from interface:JavascriptExecutorCommonly 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:
pinin 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:
getPinnedScriptsin interfaceJavascriptExecutor- Returns:
- The
ScriptKeys of all currently pinned scripts.
-
unpin
Description copied from interface:JavascriptExecutorDeletes the reference to a script that has previously been pinned. Subsequent calls toJavascriptExecutor.executeScript(ScriptKey, Object...)will fail for the givenkey.- Specified by:
unpinin interfaceJavascriptExecutor
-
executeScript
Description copied from interface:JavascriptExecutorCalls a script by theScriptKeyreturned byJavascriptExecutor.pin(String). This can be thought of as inlining the pinned script and simply callingJavascriptExecutor.executeScript(String, Object...).- Specified by:
executeScriptin interfaceJavascriptExecutor- See Also:
-
setFileDetector
Description copied from class:RemoteWebDriverSet the file detector to be used when sending keyboard input. By default, this is set to a file detector that does nothing.- Overrides:
setFileDetectorin classRemoteWebDriver- Parameters:
detector- The detector to use. Must not be null.- See Also:
-
onLogEvent
- Specified by:
onLogEventin interfaceHasLogEvents
-
register
Description copied from interface:HasAuthenticationRegisters a check for whether a set ofCredentialsshould 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:
registerin interfaceHasAuthentication
-
getLocalStorage
Deprecated.- Specified by:
getLocalStoragein interfaceWebStorage
-
getSessionStorage
Deprecated.- Specified by:
getSessionStoragein interfaceWebStorage
-
location
Deprecated.Description copied from interface:LocationContextGets the physical location of the browser.- Specified by:
locationin interfaceLocationContext- Returns:
- A
Locationcontaining the location information. Returns null if the location is not available
-
setLocation
Deprecated.Description copied from interface:LocationContextSets the physical location.- Specified by:
setLocationin interfaceLocationContext- Parameters:
location- ALocationcontaining the new location information
-
launchApp
- Specified by:
launchAppin interfaceHasLaunchApp- Parameters:
id- which Chromium app to launch.
-
executeCdpCommand
Description copied from interface:HasCdpExecute 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
DevToolsAPI instead of this- Specified by:
executeCdpCommandin 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:
maybeGetDevToolsin interfaceHasDevTools
-
maybeGetBiDi
- Specified by:
maybeGetBiDiin interfaceHasBiDi
-
getCastSinks
Description copied from interface:HasCastingReturns the list of cast sinks (Cast devices) available to the Chrome media router.- Specified by:
getCastSinksin interfaceHasCasting- Returns:
- array of ID / Name pairs of available cast sink targets
-
getCastIssueMessage
- Specified by:
getCastIssueMessagein interfaceHasCasting- Returns:
- an error message if there is any issue in a Cast session.
-
selectCastSink
Description copied from interface:HasCastingSelects a cast sink (Cast device) as the recipient of media router intents (connect or play).- Specified by:
selectCastSinkin interfaceHasCasting- Parameters:
deviceName- name of the target device.
-
startDesktopMirroring
Description copied from interface:HasCastingInitiates desktop mirroring for the current browser tab on the specified device.- Specified by:
startDesktopMirroringin interfaceHasCasting- Parameters:
deviceName- name of the target device.
-
startTabMirroring
Description copied from interface:HasCastingInitiates tab mirroring for the current browser tab on the specified device.- Specified by:
startTabMirroringin interfaceHasCasting- Parameters:
deviceName- name of the target device.
-
stopCasting
Description copied from interface:HasCastingStops casting from media router to the specified device, if connected.- Specified by:
stopCastingin interfaceHasCasting- Parameters:
deviceName- name of the target device.
-
setPermission
- Specified by:
setPermissionin interfaceHasPermissions- Parameters:
name- what item to set the permission on.value- what to set the permission to.
-
getNetworkConditions
Description copied from interface:HasNetworkConditionsGets map of network conditions. These have to be set before they can be retrieved.- Specified by:
getNetworkConditionsin interfaceHasNetworkConditions- Returns:
- the current network condition values.
-
setNetworkConditions
Description copied from interface:HasNetworkConditionsSet network limitations- Specified by:
setNetworkConditionsin interfaceHasNetworkConditions- Parameters:
networkConditions- object containing valid network condition settings.
-
deleteNetworkConditions
public void deleteNetworkConditions()Description copied from interface:HasNetworkConditionsResets the network conditions to the default settings.- Specified by:
deleteNetworkConditionsin interfaceHasNetworkConditions
-
quit
public void quit()Description copied from interface:WebDriverQuits this driver, closing every associated window.- Specified by:
quitin interfaceWebDriver- Overrides:
quitin classRemoteWebDriver
-