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

public class DriverService extends Object implements 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.
  • Field Details

  • 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

      public String getExecutable()
    • setExecutable

      public void setExecutable(String executable)
    • getArgs

      protected List<String> getArgs()
    • getEnvironment

      protected Map<String,String> getEnvironment()
    • getUrl

      protected URL getUrl(int port) throws IOException
      Throws:
      IOException
    • getDefaultDriverOptions

      protected Capabilities getDefaultDriverOptions()
    • getDriverName

      protected String getDriverName()
    • getDriverProperty

      public String getDriverProperty()
    • getDriverExecutable

      protected File getDriverExecutable()
    • getUrl

      public 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 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:
      IOException - If an error occurs while spawning the child process.
      See Also:
    • getTimeout

      protected 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:
    • hasShutdownEndpoint

      protected boolean hasShutdownEndpoint()
    • sendOutputTo

      public void sendOutputTo(OutputStream outputStream)
    • getOutputStream

      protected OutputStream getOutputStream()
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable