Class DriverService.Builder<DS extends DriverService,B extends DriverService.Builder<?,?>>
- java.lang.Object
-
- org.openqa.selenium.remote.service.DriverService.Builder<DS,B>
-
- 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 com.google.common.collect.ImmutableList<java.lang.String>
createArgs()
protected abstract DS
createDriverService(java.io.File exe, int port, com.google.common.collect.ImmutableList<java.lang.String> args, com.google.common.collect.ImmutableMap<java.lang.String,java.lang.String> environment)
protected abstract java.io.File
findDefaultExecutable()
protected java.io.File
getLogFile()
protected int
getPort()
abstract int
score(org.openqa.selenium.Capabilities capabilities)
Provides a measure of how strongly thisDriverService
supports the givencapabilities
.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.
-
-
-
Method Detail
-
score
public abstract int score(org.openqa.selenium.Capabilities capabilities)
Provides a measure of how strongly thisDriverService
supports the givencapabilities
. A score of 0 or less indicates that thisDriverService
does not support instances ofWebDriver
that requirecapabilities
. 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()
-
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 com.google.common.collect.ImmutableList<java.lang.String> createArgs()
-
createDriverService
protected abstract DS createDriverService(java.io.File exe, int port, com.google.common.collect.ImmutableList<java.lang.String> args, com.google.common.collect.ImmutableMap<java.lang.String,java.lang.String> environment)
-
-