@Beta
public class RemoteWebDriverBuilder
extends java.lang.Object
Expected usage is something like:
WebDriver driver = RemoteWebDriver.builder() .addAlternative(new FirefoxOptions()) .addAlternative(new ChromeOptions()) .addMetadata("cloud:key", "hunter2") .setCapability("proxy", new Proxy()) .build();In this example, we ask for a session where the browser will be either Firefox or Chrome (we don't care which), but where either browser will use the given
Proxy
.
In addition, we've added some metadata to the session, setting the "cloud.key
" to be the
secret passphrase of our account with the cloud "Selenium as a Service" provider.
If no call to withDriverService(DriverService)
or url(URL)
is made, the builder
will use ServiceLoader
to find all instances of DriverService.Builder
and will
call DriverService.Builder#score(Capabilities)
for each alternative until a new session
can be created.
Modifier and Type | Method and Description |
---|---|
RemoteWebDriverBuilder |
addAlternative(org.openqa.selenium.Capabilities options)
Add to the list of possible configurations that might be asked for.
|
RemoteWebDriverBuilder |
addMetadata(java.lang.String key,
java.lang.Object value)
Adds metadata to the outgoing new session request, which can be used by intermediary of end
nodes for any purpose they choose (commonly, this is used to request additional features from
cloud providers, such as video recordings or to set the timezone or screen size).
|
org.openqa.selenium.WebDriver |
build()
Actually create a new WebDriver session.
|
RemoteWebDriverBuilder |
oneOf(org.openqa.selenium.Capabilities maybeThis,
org.openqa.selenium.Capabilities... orOneOfThese)
Clears the current set of alternative browsers and instead sets the list of possible choices to
the arguments given to this method.
|
RemoteWebDriverBuilder |
setCapability(java.lang.String capabilityName,
java.lang.String value)
Sets a capability for every single alternative when the session is created.
|
RemoteWebDriverBuilder |
url(java.lang.String url) |
RemoteWebDriverBuilder |
url(java.net.URL url)
Set the URL of the remote server.
|
RemoteWebDriverBuilder |
withDriverService(DriverService service)
Use the given
DriverService to set up the webdriver instance. |
public RemoteWebDriverBuilder oneOf(org.openqa.selenium.Capabilities maybeThis, org.openqa.selenium.Capabilities... orOneOfThese)
public RemoteWebDriverBuilder addAlternative(org.openqa.selenium.Capabilities options)
public RemoteWebDriverBuilder addMetadata(java.lang.String key, java.lang.Object value)
null
.public RemoteWebDriverBuilder setCapability(java.lang.String capabilityName, java.lang.String value)
addAlternative(Capabilities)
or oneOf(Capabilities, Capabilities...)
even
after this method call.public RemoteWebDriverBuilder url(java.lang.String url)
url(URL)
public RemoteWebDriverBuilder url(java.net.URL url)
withDriverService(DriverService)
.public RemoteWebDriverBuilder withDriverService(DriverService service)
DriverService
to set up the webdriver instance. It is an error to set
both this and also call url(URL)
.public org.openqa.selenium.WebDriver build()
RemoteWebDriver
.