Class DriverService.Builder<DS extends DriverService,​B extends DriverService.Builder<?,​?>>

  • Enclosing class:
    DriverService

    public abstract static class DriverService.Builder<DS extends DriverService,​B extends DriverService.Builder<?,​?>>
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      Builder()  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      DS build()
      Creates a new service to manage the driver server.
      protected abstract java.util.List<java.lang.String> createArgs()  
      protected abstract DS createDriverService​(java.io.File exe, int port, java.time.Duration timeout, java.util.List<java.lang.String> args, java.util.Map<java.lang.String,​java.lang.String> environment)  
      protected abstract java.io.File findDefaultExecutable()  
      protected java.time.Duration getDefaultTimeout()  
      protected java.io.File getLogFile()  
      protected int getPort()  
      abstract int score​(org.openqa.selenium.Capabilities capabilities)
      Provides a measure of how strongly this DriverService supports the given capabilities.
      B usingAnyFreePort()
      Configures the driver server to start on any available port.
      B usingDriverExecutable​(java.io.File file)
      Sets which driver executable the builder will use.
      B usingPort​(int port)
      Sets which port the driver server should be started on.
      B withEnvironment​(java.util.Map<java.lang.String,​java.lang.String> environment)
      Defines the environment for the launched driver server.
      B withLogFile​(java.io.File logFile)
      Configures the driver server to write log to the given file.
      B withTimeout​(java.time.Duration timeout)
      Configures the timeout waiting for driver server to start.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Builder

        public Builder()
    • Method Detail

      • score

        public abstract int score​(org.openqa.selenium.Capabilities capabilities)
        Provides a measure of how strongly this DriverService supports the given capabilities. A score of 0 or less indicates that this DriverService does not support instances of WebDriver that require capabilities. Typically, the score is generated by summing the number of capabilities that the driver service directly supports that are unique to the driver service (that is, things like "proxy" don't tend to count to the score).
      • usingDriverExecutable

        public B usingDriverExecutable​(java.io.File file)
        Sets which driver executable the builder will use.
        Parameters:
        file - The executable to use.
        Returns:
        A self reference.
      • usingPort

        public B usingPort​(int port)
        Sets which port the driver server should be started on. A value of 0 indicates that any free port may be used.
        Parameters:
        port - The port to use; must be non-negative.
        Returns:
        A self reference.
      • getPort

        protected int getPort()
      • usingAnyFreePort

        public B usingAnyFreePort()
        Configures the driver server to start on any available port.
        Returns:
        A self reference.
      • withEnvironment

        @Beta
        public B withEnvironment​(java.util.Map<java.lang.String,​java.lang.String> environment)
        Defines the environment for the launched driver server. These settings will be inherited by every browser session launched by the server.
        Parameters:
        environment - A map of the environment variables to launch the server with.
        Returns:
        A self reference.
      • withLogFile

        public B withLogFile​(java.io.File logFile)
        Configures the driver server to write log to the given file.
        Parameters:
        logFile - A file to write log to.
        Returns:
        A self reference.
      • getLogFile

        protected java.io.File getLogFile()
      • withTimeout

        public B withTimeout​(java.time.Duration timeout)
        Configures the timeout waiting for driver server to start.
        Returns:
        A self reference.
      • getDefaultTimeout

        protected java.time.Duration getDefaultTimeout()
      • build

        public DS build()
        Creates a new service to manage the driver server. Before creating a new service, the builder will find a port for the server to listen to.
        Returns:
        The new service object.
      • findDefaultExecutable

        protected abstract java.io.File findDefaultExecutable()
      • createArgs

        protected abstract java.util.List<java.lang.String> createArgs()
      • createDriverService

        protected abstract DS createDriverService​(java.io.File exe,
                                                  int port,
                                                  java.time.Duration timeout,
                                                  java.util.List<java.lang.String> args,
                                                  java.util.Map<java.lang.String,​java.lang.String> environment)