Package org.openqa.selenium.remote
Class RemoteWebDriverBuilder
- java.lang.Object
-
- org.openqa.selenium.remote.RemoteWebDriverBuilder
-
@Beta public class RemoteWebDriverBuilder extends java.lang.Object
Create a new Selenium session using the W3C WebDriver protocol. This class will not generate any data expected by the original JSON Wire Protocol, so will fail to create sessions as expected if used against a server that only implements that protocol.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 givenProxy
. 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)
oraddress(URI)
is made, the builder will useServiceLoader
to find all instances ofWebDriverInfo
and will callWebDriverInfo.createDriver(Capabilities)
for the first supported set of capabilities.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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).RemoteWebDriverBuilder
address(java.lang.String uri)
RemoteWebDriverBuilder
address(java.net.URI uri)
Set the URI of the remote server.RemoteWebDriverBuilder
address(java.net.URL url)
org.openqa.selenium.WebDriver
build()
Actually create a new WebDriver session.RemoteWebDriverBuilder
config(org.openqa.selenium.remote.http.ClientConfig config)
Allows precise control of theClientConfig
to use with remote instances.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.Object value)
Sets a capability for every single alternative when the session is created.RemoteWebDriverBuilder
withDriverService(DriverService service)
Use the givenDriverService
to set up the webdriver instance.
-
-
-
Method Detail
-
oneOf
public 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.
-
addAlternative
public RemoteWebDriverBuilder addAlternative(org.openqa.selenium.Capabilities options)
Add to the list of possible configurations that might be asked for. It is possible to ask for more than one type of browser per session. For example, perhaps you have an extension that is available for two different kinds of browser, and you'd like to test it).
-
addMetadata
public 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). Neither parameter can benull
.
-
setCapability
public RemoteWebDriverBuilder setCapability(java.lang.String capabilityName, java.lang.Object value)
Sets a capability for every single alternative when the session is created. These capabilities are only set once the session is created, so this will be set on capabilities added viaaddAlternative(Capabilities)
oroneOf(Capabilities, Capabilities...)
even after this method call.
-
address
public RemoteWebDriverBuilder address(java.lang.String uri)
- See Also:
address(URI)
-
address
public RemoteWebDriverBuilder address(java.net.URL url)
- See Also:
address(URI)
-
address
public RemoteWebDriverBuilder address(java.net.URI uri)
Set the URI of the remote server. If this URI is not set, then it assumed that a local running remote webdriver session is needed. It is an error to call this method and alsowithDriverService(DriverService)
.
-
config
public RemoteWebDriverBuilder config(org.openqa.selenium.remote.http.ClientConfig config)
Allows precise control of theClientConfig
to use with remote instances. IfClientConfig.baseUri(URI)
has been called, then that will be used as the base URI for the session.
-
withDriverService
public RemoteWebDriverBuilder withDriverService(DriverService service)
Use the givenDriverService
to set up the webdriver instance. It is an error to set both this and also calladdress(URI)
.
-
build
public org.openqa.selenium.WebDriver build()
Actually create a new WebDriver session. The returned webdriver is not guaranteed to be aRemoteWebDriver
.
-
-