public static class Settings.Builder extends Object
JBrowserDriver.JBrowserDriver.JBrowserDriver(Settings)| Constructor and Description |
|---|
Builder() |
| Modifier and Type | Method and Description |
|---|---|
Settings.Builder |
ajaxResourceTimeout(long timeoutMS)
The time in milliseconds after which an AJAX request will be ignored when considering
whether all AJAX requests have completed.
|
Settings.Builder |
ajaxWait(long intervalMS)
The idle time (no pending AJAX requests) required in milliseconds before a page is considered to have been loaded completely.
|
Settings.Builder |
blockAds(boolean blockAds)
Whether requests to ad/spam servers should be blocked.
|
Settings |
build() |
Capabilities |
buildCapabilities() |
Settings.Builder |
cache(boolean cache)
Whether to cache web pages like a desktop browser would.
|
Settings.Builder |
cacheDir(File cacheDir)
Directory where the web cache resides--this enables sharing a cache across instances and after JVM restarts.
|
Settings.Builder |
cacheEntries(int cacheEntries)
Set maximum number of cached files on disk.
|
Settings.Builder |
cacheEntrySize(long bytes)
Set maximum size of a file to be cached.
|
Settings.Builder |
connectionReqTimeout(int timeoutMS)
Connection request timeout in milliseconds,
which is the max time to wait when the max number of connections has already been reached.
|
Settings.Builder |
connectTimeout(int timeoutMS)
Connect timeout in milliseconds, which the is max time until a connection is established.
|
Settings.Builder |
csrf()
Enables CSRF token handling.
|
Settings.Builder |
csrf(String requestToken,
String responseToken)
Enables CSRF token handling
|
Settings.Builder |
headless(boolean headless)
Whether to run in headless mode (no GUI windows).
|
Settings.Builder |
headScript(String headScript)
Script to be injected in the HTML Head section.
|
Settings.Builder |
hostnameVerification(boolean hostnameVerification)
Whether the hostname in certificates should be verified.
|
Settings.Builder |
ignoreDialogs(boolean ignoreDialogs)
Whether JavaScript alerts, prompts, and confirm dialogs should be auto-dismissed
and ignored.
|
Settings.Builder |
javaBinary(String javaBinary)
The path to the Java executable or the Java command used to launch child JRE browser processes.
|
Settings.Builder |
javaExportModules(boolean javaExportModules)
Allows this library to run on Java 9.
|
Settings.Builder |
javaOptions(String... options)
JVM options, such as Java system properties or Java HotSpot VM options.
|
Settings.Builder |
javascript(boolean isEnabled)
Whether javascript is enabled in the browser.
|
Settings.Builder |
localIp(InetAddress nicAddress)
Used for binding to a specific NIC
|
Settings.Builder |
logger(String name)
The name of a Java Logger to handle log messages.
|
Settings.Builder |
loggerLevel(Level loggerLevel)
At what log level the logger should log
|
Settings.Builder |
logJavascript(boolean logJavascript)
Log the browser console output.
|
Settings.Builder |
logsMax(int logsMax)
Maximum number of log messages (per log type) to store in memory (per process),
accessible via the Selenium logging APIs.
|
Settings.Builder |
logTrace(boolean logTrace)
Log details of HTTP requests performed and other info useful for monitoring runtime performance.
|
Settings.Builder |
logWarnings(boolean logWarnings)
Log errors, exceptions, and important notices.
|
Settings.Builder |
logWire(boolean logWire)
Log full requests and responses (excluding response bodies).
|
Settings.Builder |
maxConnections(int maxConnections)
Maximum number of concurrent connections overall (per process).
|
Settings.Builder |
maxRouteConnections(int maxRouteConnections)
Maximum number of concurrent connections (per process) to a specific host+proxy combo.
|
Settings.Builder |
processes(int maxProcesses)
The number of
JBrowserDriver instances that can run concurrently, using any available port. |
Settings.Builder |
processes(int maxProcesses,
String host)
The number of
JBrowserDriver instances that can run concurrently,
using any available port, and the host name or IP of the local machine. |
Settings.Builder |
processes(String portRanges)
The ports used by
JBrowserDriver instances and the parent process. |
Settings.Builder |
processes(String portRanges,
String host)
The ports and host/IP used by
JBrowserDriver instances and the parent process. |
Settings.Builder |
proxy(ProxyConfig proxy)
Proxy server to be used.
|
Settings.Builder |
quickRender(boolean quickRender)
Exclude web page images and binary data from rendering.
|
Settings.Builder |
requestHeaders(RequestHeaders requestHeaders)
Headers to be sent on each request.
|
Settings.Builder |
saveAttachments(boolean saveAttachments)
Whether to save links to disk when prompted by the browser.
|
Settings.Builder |
saveMedia(boolean saveMedia)
Whether to save media (e.g., images) to disk.
|
Settings.Builder |
screen(Dimension screen)
Size of the screen and initial size of the window.
|
Settings.Builder |
socketTimeout(int timeoutMS)
Socket timeout in milliseconds, which is the max idle time between any two packets.
|
Settings.Builder |
ssl(String ssl)
Specifies a source of trusted certificate authorities.
|
Settings.Builder |
timezone(Timezone timezone)
Timezone of the browser.
|
Settings.Builder |
userAgent(UserAgent userAgent)
User agent and window.navigator properties.
|
Settings.Builder |
userDataDirectory(File userDataDirectory)
User data/local storage directory used by the browser.
|
public Settings.Builder ajaxResourceTimeout(long timeoutMS)
Defaults to 2000.
jbd.ajaxresourcetimeout overrides this setting.Capabilities name jbd.ajaxresourcetimeout alternately configures this setting.timeoutMS - public Settings.Builder ajaxWait(long intervalMS)
For very slow or overloaded CPUs, set a higher value.
Defaults to 150.
jbd.ajaxwait overrides this setting.Capabilities name jbd.ajaxwait alternately configures this setting.intervalMS - public Settings.Builder blockAds(boolean blockAds)
Based on hosts in ad-hosts.txt in the source tree.
Defaults to false.
jbd.blockads overrides this setting.Capabilities name jbd.blockads alternately configures this setting.blockAds - public Settings build()
JBrowserDriver.JBrowserDriver(Settings)public Capabilities buildCapabilities()
public Settings.Builder cache(boolean cache)
The temporary directory where these files are saved is availble from
JBrowserDriver.cacheDir()
Defaults to false.
jbd.cache overrides this setting.Capabilities name jbd.cache alternately configures this setting.cache - public Settings.Builder cacheDir(File cacheDir)
Defaults to null meaning a temp directory will be generated, available via JBrowserDriver.cacheDir().
jbd.cachedir overrides this setting.Capabilities name jbd.cachedir alternately configures this setting.cacheDir - cache directorypublic Settings.Builder cacheEntries(int cacheEntries)
Defaults to 10000.
jbd.cacheentries overrides this setting.Capabilities name jbd.cacheentries alternately configures this setting.cacheEntries - public Settings.Builder cacheEntrySize(long bytes)
Defaults to 1 MB.
jbd.cacheentrysize overrides this setting.Capabilities name jbd.cacheentrysize alternately configures this setting.bytes - public Settings.Builder connectionReqTimeout(int timeoutMS)
When the timeout is reached, the connection fails with an exception. Value of 0 means infinite timeout.
Defaults to -1 (system default).
jbd.connectionreqtimeout overrides this setting.Capabilities name jbd.connectionreqtimeout alternately configures this setting.timeoutMS - Timeout in millisecondspublic Settings.Builder connectTimeout(int timeoutMS)
Value of 0 means infinite timeout.
Defaults to -1 (system default).
jbd.connecttimeout overrides this setting.Capabilities name jbd.connecttimeout alternately configures this setting.timeoutMS - Timeout in millisecondspublic Settings.Builder csrf()
public Settings.Builder csrf(String requestToken, String responseToken)
requestToken - The header to send in each request headerresponseToken - The token to search for in response headerspublic Settings.Builder headless(boolean headless)
Screenshots are available in headless mode (see JBrowserDriver.getScreenshotAs(org.openqa.selenium.OutputType)).
Defaults to true.
jbd.headless overrides this setting.Capabilities name jbd.headless alternately configures this setting.headless - public Settings.Builder headScript(String headScript)
Omit <script> tags; they will be added automatically.
Defaults to Settings.HEAD_SCRIPT.
jbd.headscript overrides this setting.Capabilities name jbd.headscript alternately configures this setting.headScript - Script to be injectedpublic Settings.Builder hostnameVerification(boolean hostnameVerification)
Defaults to true.
jbd.hostnameverification overrides this setting.Capabilities name jbd.hostnameverification alternately configures this setting.hostnameVerification - public Settings.Builder ignoreDialogs(boolean ignoreDialogs)
Note that if dialogs are not ignored and you are handling them, that calls to alert.accept(), alert.dismiss(), and alert.sendKeys(String) are queued, so there is no need to wait for the dialog to actually be displayed and these calls will not block. Calls to alert.getText() block until an alert is shown (unless a script timeout is reached first).
Defaults to true.
jbd.ignoredialogs overrides this setting.Capabilities name jbd.ignoredialogs alternately configures this setting.ignoreDialogs - True to auto-dismiss alert/prompt/confirm dialogs and relieve the
user from having to handle them. False to allow these dialogs to have an effect on the page
and force the user to accept/dismiss them.public Settings.Builder javaBinary(String javaBinary)
Defaults to null, meaning that the same Java executable running the parent process will be used to launch the child processes.
jbd.javabinary overrides this setting.Capabilities name jbd.javabinary alternately configures this setting.javaBinary - public Settings.Builder javaExportModules(boolean javaExportModules)
Defaults to false (i.e., Java 8 compatible).
jbd.javaexportmodules overrides this setting.Capabilities name jbd.javaexportmodules alternately configures this setting.javaExportModules - public Settings.Builder javaOptions(String... options)
Each option is a separate string in the array passed in. E.g.,
.javaOptions("-XX:+PrintCommandLineFlags", "-Xmx1g", "-Djsse.enableSNIExtension=false")
Note that browser instances are run in a separate Java process which doesn't inherit any options set in the parent process (thus the need for this API).
By default no options are set.
jbd.javaoptions overrides this setting. The options must be separated by tab (\t).Capabilities name jbd.javaoptions alternately configures this setting. The options must be separated by tab (\t).options - public Settings.Builder javascript(boolean isEnabled)
Defaults to true.
jbd.javascript overrides this setting.Capabilities name jbd.javascript alternately configures this setting.isEnabled - true to enable Javascript, false otherwisepublic Settings.Builder localIp(InetAddress nicAddress)
nicAddress - public Settings.Builder logger(String name)
Logs are also available via the Selenium logging APIs--this logger has no effect on that.
The name can be null or "" meaning no Java Logger will be used.
Defaults to com.machinepublishers.jbrowserdriver which echos messages to standard out/error.
jbd.logger overrides this setting.Capabilities name jbd.logger alternately configures this setting.name - public Settings.Builder loggerLevel(Level loggerLevel)
Defaults to Level.ALL
The loggerLevel can be null meaning no logging will be done.
loggerLevel - public Settings.Builder logJavascript(boolean logJavascript)
Defaults to false
jbd.logjavascript overrides this setting.Capabilities name jbd.logjavascript alternately configures this setting.logJavascript - public Settings.Builder logsMax(int logsMax)
Logs are also available via a Java Logger--this max has no effect on that.
The oldest log entry is dropped once the max is reached. Regardless of this setting, logs are cleared per instance of JBrowserDriver after a call to quit(), reset(), or Logs.get(String).
A value of zero disables Selenium logging.
Defaults to 1000.
jbd.logsmax overrides this setting.Capabilities name jbd.logsmax alternately configures this setting.logsMax - public Settings.Builder logTrace(boolean logTrace)
Defaults to false
jbd.logtrace overrides this setting.Capabilities name jbd.logtrace alternately configures this setting.logTrace - public Settings.Builder logWarnings(boolean logWarnings)
Defaults to true
jbd.logwarnings overrides this setting.Capabilities name jbd.logwarnings alternately configures this setting.logWarnings - public Settings.Builder logWire(boolean logWire)
Defaults to false
jbd.logwire overrides this setting.Capabilities name jbd.logwire alternately configures this setting.logWire - public Settings.Builder maxConnections(int maxConnections)
Defaults to 300.
jbd.maxconnections overrides this setting.Capabilities name jbd.maxconnections alternately configures this setting.maxConnections - public Settings.Builder maxRouteConnections(int maxRouteConnections)
Defaults to 8.
jbd.maxrouteconnections overrides this setting.Capabilities name jbd.maxrouteconnections alternately configures this setting.maxRouteConnections - public Settings.Builder processes(int maxProcesses)
JBrowserDriver instances that can run concurrently, using any available port.
Each instance of JBrowserDriver is backed by a separate Java process operated via RMI.
Overwrites settings specified by any previous calls to processes(..)
By default any available ports are used, the host is 127.0.0.1, and the max number of concurrent
instances is 2 * Runtime.getRuntime().availableProcessors()
jbd.processes overrides this setting.Capabilities name jbd.processes alternately configures this setting.maxProcesses - public Settings.Builder processes(int maxProcesses, String host)
JBrowserDriver instances that can run concurrently,
using any available port, and the host name or IP of the local machine.
Each instance of JBrowserDriver is backed by a separate Java process operated via RMI.
Overwrites settings specified by any previous calls to processes(..)
By default any available ports are used, the host is 127.0.0.1, and the max number of concurrent
instances is 2 * Runtime.getRuntime().availableProcessors()
jbd.processes and jbd.host override this setting.Capabilities name jbd.processes and jbd.host alternately configure this setting.maxProcesses - host - public Settings.Builder processes(String portRanges)
JBrowserDriver instances and the parent process.
The max number of instances that can run concurrently is inferred from the number of ports provided (every instance requires three ports -- e.g., for up to 8 instances you need 24 ports).
Each instance of JBrowserDriver is backed by a separate Java process operated via RMI.
Overwrites settings specified by any previous calls to processes(..)
By default any available ports are used, the host is 127.0.0.1, and the max number of concurrent
instances is 2 * Runtime.getRuntime().availableProcessors()
jbd.portranges overrides this setting.Capabilities name jbd.portranges alternately configures this setting.portRanges - A comma separated list of ports and/or port ranges
(ranges are inclusive and separated by a dash) -- e.g., 10000-10007,12500,12502,15376-15380public Settings.Builder processes(String portRanges, String host)
JBrowserDriver instances and the parent process.
The max number of instances that can run concurrently is inferred from the number of ports provided (every instance requires three ports -- e.g., for up to 8 instances you need 24 ports).
Each instance of JBrowserDriver is backed by a separate Java process operated via RMI.
Overwrites settings specified by any previous calls to processes(..)
By default any available ports are used, the host is 127.0.0.1, and the max number of concurrent
instances is 2 * Runtime.getRuntime().availableProcessors()
jbd.portranges and jbd.host override this setting.Capabilities names jbd.portranges and jbd.host alternately configure this setting.portRanges - A comma separated list of ports and/or port ranges
(ranges are inclusive and separated by a dash) -- e.g., 10000-10007,12500,12502,15376-15380host - public Settings.Builder proxy(ProxyConfig proxy)
Defaults to a direct connection (no proxy).
jbd.proxytype, jbd.proxyhost, jbd.proxyport, jbd.proxyusername, jbd.proxypassword, and
jbd.proxyexpectcontinue override this setting.Capabilities names jbd.proxytype, jbd.proxyhost, jbd.proxyport, jbd.proxyusername, jbd.proxypassword, and
jbd.proxyexpectcontinue alternately configure this setting.proxy - Proxy configuration or null.public Settings.Builder quickRender(boolean quickRender)
These resources are still requested and can optionally be saved to disk (see the Settings options). Some older versions of Java are inefficient (memory-wise) in rendering images.
Defaults to false.
jbd.quickrender overrides this setting.Capabilities name jbd.quickrender alternately configures this setting.quickRender - public Settings.Builder requestHeaders(RequestHeaders requestHeaders)
Defaults to RequestHeaders.TOR.
(Not configurable via Java system properties or Capabilities. See userAgent(UserAgent) instead.)
requestHeaders - userAgent(UserAgent)public Settings.Builder saveAttachments(boolean saveAttachments)
Attachments are saved as two files in the mediaDir: <identifier>.content (which has the binary content) and <identifier>.metadata (the first line of this file is the URL of the request for this media, the second line is the Content-Type header, and the third line is the Content-Disposition header).
Saved files are deleted when the JVM exits, so copy them to a different location to persist them permanently.
The temporary directory where these files are saved is availble from
JBrowserDriver.attachmentsDir()
Defaults to false.
jbd.saveattachments overrides this setting.Capabilities name jbd.saveattachments alternately configures this setting.saveAttachments - public Settings.Builder saveMedia(boolean saveMedia)
Media is saved as two files in the mediaDir: <identifier>.content (which has the binary content) and <identifier>.metadata (the first line of this file is the URL of the request for this media, the second line is the Content-Type header, and the third line is the Content-Disposition header).
Saved media files are deleted when the JVM exits, so copy them to a different location to persist them permanently.
The temporary directory where these files are saved is availble from
JBrowserDriver.mediaDir()
Defaults to false.
jbd.savemedia overrides this setting.Capabilities name jbd.savemedia alternately configures this setting.saveMedia - Whether to save media (e.g., images) to disk.public Settings.Builder screen(Dimension screen)
Defaults to 1000x600. This is a typical size for Tor Browser but if you're not using the Tor user agent you might want to specify a more common size such as 1366x768.
jbd.screenwidth and jbd.screenheight override this setting.Capabilities names jbd.screenwidth and jbd.screenheight alternately configure this setting.screen - Screen and window size.public Settings.Builder socketTimeout(int timeoutMS)
Value of 0 means infinite timeout.
Defaults to -1 (system default).
jbd.sockettimeout overrides this setting.Capabilities name jbd.sockettimeout alternately configures this setting.timeoutMS - Timeout in millisecondspublic Settings.Builder ssl(String ssl)
Can take one of four values:
(1) compatible to accept standard browser certs,
(2) trustanything to accept any SSL cert,
(3) a file path, or
(4) a URL.
If a file or URL is specified it must follow exactly the format of content like this: https://raw.githubusercontent.com/bagder/ca-bundle/master/ca-bundle.crt
The default when this property is not set (i.e., when it's null) is your JRE's keystore,
so you can use JDK's keytool to import specific certs.
jbd.ssl overrides this setting.Capabilities name jbd.ssl alternately configures this setting.ssl - public Settings.Builder timezone(Timezone timezone)
Defaults to Timezone.UTC.
This is the timezone of Tor Browser but if you're not using the Tor user agent
you might want to use a locale nearer your actual computer,
such as Timezone.AMERICA_LOSANGELES if you're in San Francisco.
jbd.timezone overrides this setting. For value, see Timezone.name().Capabilities name jbd.timezone alternately configures this setting. For value, see Timezone.name().timezone - Timezone of the browser.public Settings.Builder userAgent(UserAgent userAgent)
Defaults to UserAgent.TOR.
jbd.useragent overrides this setting and the requestHeaders(RequestHeaders) setting. The value must be one of: tor, chrome.Capabilities name jbd.useragent alternately configures this setting and the requestHeaders(RequestHeaders) setting. The value must be one of: tor,
chrome.userAgent - Browser's user agentrequestHeaders(RequestHeaders)public Settings.Builder userDataDirectory(File userDataDirectory)
Defaults to null, meaning that a temp directory will be automatically created and destroyed as needed for user data.
jbd.userdatadirectory overrides this setting. Use a string file path as the value.Capabilities name jbd.userdatadirectory alternately configures this setting. Use a string file path as the value.userDataDirectory - A directory to store user website data, e.g. localStorage.WebEngine.userDataDirectoryCopyright © 2014-2017 jBrowserDriver committers.
Project homepage: https://github.com/machinepublishers/jbrowserdriver