Class DriverService
java.lang.Object
org.openqa.selenium.remote.service.DriverService
- All Implemented Interfaces:
Closeable
,AutoCloseable
- Direct Known Subclasses:
ChromeDriverService
,EdgeDriverService
,FirefoxDriverService
,InternetExplorerDriverService
,SafariDriverService
,SafariTechPreviewDriverService
Manages the life and death of a native executable driver server. It is expected that the driver
server implements the WebDriver Wire Protocol.
In particular, it should implement /status command that is used to check if the server is alive.
In addition to this, it is supposed that the driver server implements /shutdown hook that is used
to stop the server.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
DriverService.Builder<DS extends DriverService,
B extends DriverService.Builder<?, ?>> -
Field Summary
Modifier and TypeFieldDescriptionprotected static final Duration
static final String
static final String
static final String
protected ExternalProcess
A reference to the current child process. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
getArgs()
protected Capabilities
protected File
protected String
protected OutputStream
protected Duration
getUrl()
protected URL
getUrl
(int port) protected boolean
boolean
Checks whether the driver child process is currently running.void
sendOutputTo
(OutputStream outputStream) void
setExecutable
(String executable) void
start()
Starts this service if it is not already running.void
stop()
Stops this service if it is currently running.protected void
-
Field Details
-
LOG_NULL
- See Also:
-
LOG_STDERR
- See Also:
-
LOG_STDOUT
- See Also:
-
DEFAULT_TIMEOUT
-
process
A reference to the current child process. Will benull
whenever this service is not running. Protected bylock
.
-
-
Constructor Details
-
DriverService
protected DriverService(File executable, int port, Duration timeout, List<String> args, Map<String, String> environment) throws IOException- Parameters:
executable
- The driver executable.port
- Which port to start the driver server on.timeout
- Timeout waiting for driver server to start.args
- The arguments to the launched server.environment
- The environment for the launched server.- Throws:
IOException
- If an I/O error occurs.
-
-
Method Details
-
getExecutable
-
setExecutable
-
getArgs
-
getEnvironment
-
getUrl
- Throws:
IOException
-
getDefaultDriverOptions
-
getDriverName
-
getDriverProperty
-
getDriverExecutable
-
getUrl
- Returns:
- The base URL for the managed driver server.
-
isRunning
public boolean isRunning()Checks whether the driver child process is currently running.- Returns:
- Whether the driver child process is still running.
-
start
Starts this service if it is not already running. This method will block until the server has been fully started and is ready to handle commands.- Throws:
IOException
- If an error occurs while spawning the child process.- See Also:
-
getTimeout
-
waitUntilAvailable
protected void waitUntilAvailable() -
stop
public void stop()Stops this service if it is currently running. This method will attempt to block until the server has been fully shutdown.- See Also:
-
hasShutdownEndpoint
protected boolean hasShutdownEndpoint() -
sendOutputTo
-
getOutputStream
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-