Class DriverService
- java.lang.Object
-
- org.openqa.selenium.remote.service.DriverService
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public class DriverService extends java.lang.Object implements java.io.Closeable
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
Nested Classes Modifier and Type Class Description static class
DriverService.Builder<DS extends DriverService,B extends DriverService.Builder<?,?>>
-
Field Summary
Fields Modifier and Type Field Description protected static java.time.Duration
DEFAULT_TIMEOUT
protected CommandLine
process
A reference to the current child process.
-
Constructor Summary
Constructors Modifier Constructor Description protected
DriverService(java.io.File executable, int port, java.time.Duration timeout, java.util.List<java.lang.String> args, java.util.Map<java.lang.String,java.lang.String> environment)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
protected static java.lang.String
findExePath(java.lang.String exeName, java.lang.String exeProperty)
protected java.util.List<java.lang.String>
getArgs()
protected org.openqa.selenium.Capabilities
getDefaultDriverOptions()
protected java.io.File
getDriverExecutable()
protected java.lang.String
getDriverName()
protected java.lang.String
getDriverProperty()
protected java.util.Map<java.lang.String,java.lang.String>
getEnvironment()
java.lang.String
getExecutable()
protected java.io.OutputStream
getOutputStream()
protected java.time.Duration
getTimeout()
java.net.URL
getUrl()
protected java.net.URL
getUrl(int port)
protected boolean
hasShutdownEndpoint()
boolean
isRunning()
Checks whether the driver child process is currently running.void
sendOutputTo(java.io.OutputStream outputStream)
void
setExecutable(java.lang.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
waitUntilAvailable()
-
-
-
Field Detail
-
DEFAULT_TIMEOUT
protected static final java.time.Duration DEFAULT_TIMEOUT
-
process
protected CommandLine process
A reference to the current child process. Will benull
whenever this service is not running. Protected bylock
.
-
-
Constructor Detail
-
DriverService
protected DriverService(java.io.File executable, int port, java.time.Duration timeout, java.util.List<java.lang.String> args, java.util.Map<java.lang.String,java.lang.String> environment) throws java.io.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:
java.io.IOException
- If an I/O error occurs.
-
-
Method Detail
-
getExecutable
public java.lang.String getExecutable()
-
setExecutable
public void setExecutable(java.lang.String executable)
-
findExePath
protected static java.lang.String findExePath(java.lang.String exeName, java.lang.String exeProperty)
-
getArgs
protected java.util.List<java.lang.String> getArgs()
-
getEnvironment
protected java.util.Map<java.lang.String,java.lang.String> getEnvironment()
-
getUrl
protected java.net.URL getUrl(int port) throws java.io.IOException
- Throws:
java.io.IOException
-
getDefaultDriverOptions
protected org.openqa.selenium.Capabilities getDefaultDriverOptions()
-
getDriverName
protected java.lang.String getDriverName()
-
getDriverProperty
protected java.lang.String getDriverProperty()
-
getDriverExecutable
protected java.io.File getDriverExecutable()
-
getUrl
public java.net.URL 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
public void start() throws java.io.IOException
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:
java.io.IOException
- If an error occurs while spawning the child process.- See Also:
stop()
-
getTimeout
protected java.time.Duration 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:
start()
-
hasShutdownEndpoint
protected boolean hasShutdownEndpoint()
-
sendOutputTo
public void sendOutputTo(java.io.OutputStream outputStream)
-
getOutputStream
protected java.io.OutputStream getOutputStream()
-
close
public void close()
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
-
-