selenium-webdriver
Version:
The official WebDriver JavaScript bindings from the Selenium project
127 lines (125 loc) • 23.7 kB
HTML
<meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no"><meta http-equiv="Content-Language" content="en"><meta http-equiv="X-UA-Compatible" content="IE=edge"><title>Options</title><link href="dossier.css" rel="stylesheet" type="text/css"><header><div><form><div><input type="search" placeholder="Search" tabindex="1"></div></form></div></header><main><article><div class="parentlink"><b>Module:</b> <a href="module_selenium-webdriver_chrome.html">selenium-webdriver/chrome</a></div><div class="codelink"><a href="source/chrome.js.src.html#l845">View Source</a></div><h1>class Options</h1><pre class="inheritance"><a href="class_webdriver_Serializable.html">webdriver.Serializable</a>
└ Options</pre><p>Class for managing ChromeDriver specific options.</p>
<h3>new Options()</h3><div><div class="fn-details"><div><b>Parameters</b></div><dl><dd>None.</dl></div></div><h2>Instance Methods</h2><div id="addArguments" class="function"><div><h3>addArguments(<wbr>var_args)<span class="codelink"><a href="source/chrome.js.src.html#l447">code »</a></span></h3><p>Add additional command line arguments to use when launching the Chrome
browser. Each argument may be specified with or without the "--" prefix
(e.g. "--foo" and "foo"). Arguments with an associated value should be
delimited by an "=": "foo=bar".</p>
<div><div class="fn-details"><div><b>Parameters</b></div><dl><dt>var_args<code>...(<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>|<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a><<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>>)</code><dd><p>The arguments to add.</p>
</dl></div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="module_selenium-webdriver_chrome_class_Options.html">Options</a></code><dd><p>A self reference.</p>
</dl></div></div></div></div><hr class="fn-sep"><div id="addExtensions" class="function"><div><h3>addExtensions(<wbr>var_args)<span class="codelink"><a href="source/chrome.js.src.html#l482">code »</a></span></h3><p>Add additional extensions to install when launching Chrome. Each extension
should be specified as the path to the packed CRX file, or a Buffer for an
extension.</p>
<div><div class="fn-details"><div><b>Parameters</b></div><dl><dt>var_args<code>...(<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>|Buffer|<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a><(<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>|Buffer)>)</code><dd><p>The
extensions to add.</p>
</dl></div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="module_selenium-webdriver_chrome_class_Options.html">Options</a></code><dd><p>A self reference.</p>
</dl></div></div></div></div><hr class="fn-sep"><div id="androidActivity" class="function"><div><h3>androidActivity(<wbr>name)<span class="codelink"><a href="source/chrome.js.src.html#l592">code »</a></span></h3><p>Sets the name of the activity hosting a Chrome-based Android WebView. This
option must be set to connect to an <a href="https://sites.google.com/a/chromium.org/chromedriver/getting-started/getting-started---android">Android WebView</a></p>
<div><div class="fn-details"><div><b>Parameters</b></div><dl><dt>name<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd><p>The activity name.</p>
</dl></div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="module_selenium-webdriver_chrome_class_Options.html">Options</a></code><dd><p>A self reference.</p>
</dl></div></div></div></div><hr class="fn-sep"><div id="androidChrome" class="function"><div><h3>androidChrome()<span class="codelink"><a href="source/chrome.js.src.html#l618">code »</a></span></h3><p>Configures the ChromeDriver to launch Chrome on Android via adb. This
function is shorthand for
<a href="module_selenium-webdriver_chrome_class_Options.html#androidPackage"><code>options.androidPackage('com.android.chrome')</code></a>.</p>
<div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="module_selenium-webdriver_chrome_class_Options.html">Options</a></code><dd><p>A self reference.</p>
</dl></div></div></div></div><hr class="fn-sep"><div id="androidDeviceSerial" class="function"><div><h3>androidDeviceSerial(<wbr>serial)<span class="codelink"><a href="source/chrome.js.src.html#l606">code »</a></span></h3><p>Sets the device serial number to connect to via ADB. If not specified, the
ChromeDriver will select an unused device at random. An error will be
returned if all devices already have active sessions.</p>
<div><div class="fn-details"><div><b>Parameters</b></div><dl><dt>serial<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd><p>The device serial number to connect to.</p>
</dl></div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="module_selenium-webdriver_chrome_class_Options.html">Options</a></code><dd><p>A self reference.</p>
</dl></div></div></div></div><hr class="fn-sep"><div id="androidPackage" class="function"><div><h3>androidPackage(<wbr>pkg)<span class="codelink"><a href="source/chrome.js.src.html#l630">code »</a></span></h3><p>Sets the package name of the Chrome or WebView app.</p>
<div><div class="fn-details"><div><b>Parameters</b></div><dl><dt>pkg<code>?<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd><p>The package to connect to, or <code>null</code> to disable Android
and switch back to using desktop Chrome.</p>
</dl></div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="module_selenium-webdriver_chrome_class_Options.html">Options</a></code><dd><p>A self reference.</p>
</dl></div></div></div></div><hr class="fn-sep"><div id="androidProcess" class="function"><div><h3>androidProcess(<wbr>processName)<span class="codelink"><a href="source/chrome.js.src.html#l644">code »</a></span></h3><p>Sets the process name of the Activity hosting the WebView (as given by <code>ps</code>).
If not specified, the process name is assumed to be the same as
<a href="module_selenium-webdriver_chrome_class_Options.html#androidPackage"><code>#androidPackage</code></a>.</p>
<div><div class="fn-details"><div><b>Parameters</b></div><dl><dt>processName<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd><p>The main activity name.</p>
</dl></div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="module_selenium-webdriver_chrome_class_Options.html">Options</a></code><dd><p>A self reference.</p>
</dl></div></div></div></div><hr class="fn-sep"><div id="androidUseRunningApp" class="function"><div><h3>androidUseRunningApp(<wbr>useRunning)<span class="codelink"><a href="source/chrome.js.src.html#l658">code »</a></span></h3><p>Sets whether to connect to an already-running instead of the specified
<a href="module_selenium-webdriver_chrome_class_Options.html#androidProcess">app</a> instead of launching the app with a clean
data directory.</p>
<div><div class="fn-details"><div><b>Parameters</b></div><dl><dt>useRunning<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code><dd><p>Whether to connect to a running instance.</p>
</dl></div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="module_selenium-webdriver_chrome_class_Options.html">Options</a></code><dd><p>A self reference.</p>
</dl></div></div></div></div><hr class="fn-sep"><div id="detachDriver" class="function"><div><h3>detachDriver(<wbr>detach)<span class="codelink"><a href="source/chrome.js.src.html#l513">code »</a></span></h3><p>Sets whether to leave the started Chrome browser running if the controlling
ChromeDriver service is killed before <a href="class_webdriver_WebDriver.html#quit"><code>webdriver.WebDriver#quit()</code></a> is
called.</p>
<div><div class="fn-details"><div><b>Parameters</b></div><dl><dt>detach<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code><dd><p>Whether to leave the browser running if the
chromedriver service is killed before the session.</p>
</dl></div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="module_selenium-webdriver_chrome_class_Options.html">Options</a></code><dd><p>A self reference.</p>
</dl></div></div></div></div><hr class="fn-sep"><div id="excludeSwitches" class="function"><div><h3>excludeSwitches(<wbr>var_args)<span class="codelink"><a href="source/chrome.js.src.html#l464">code »</a></span></h3><p>List of Chrome command line switches to exclude that ChromeDriver by default
passes when starting Chrome. Do not prefix switches with "--".</p>
<div><div class="fn-details"><div><b>Parameters</b></div><dl><dt>var_args<code>...(<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>|<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a><<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>>)</code><dd><p>The switches to exclude.</p>
</dl></div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="module_selenium-webdriver_chrome_class_Options.html">Options</a></code><dd><p>A self reference.</p>
</dl></div></div></div></div><hr class="fn-sep"><div id="serialize" class="function"><div><h3>serialize()<span class="codelink"><a href="source/chrome.js.src.html#l770">code »</a></span></h3><p>Converts this instance to its JSON wire protocol representation. Note this
function is an implementation not intended for general use.</p>
<p><b>Overrides: </b><a href="class_webdriver_Serializable.html#serialize">webdriver.Serializable</a></p><div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code>{args: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a><<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>>, binary: (<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>|<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Undefined">undefined</a>), detach: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a>, extensions: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a><(<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>|<a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a>)>, localState: ?(<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>), logPath: (<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>|<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Undefined">undefined</a>), prefs: ?(<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>)}</code><dd><p>The JSON wire protocol representation
of this instance.</p>
</dl></div></div></div></div><hr class="fn-sep"><div id="setChromeBinaryPath" class="function"><div><h3>setChromeBinaryPath(<wbr>path)<span class="codelink"><a href="source/chrome.js.src.html#l499">code »</a></span></h3><p>Sets the path to the Chrome binary to use. On Mac OS X, this path should
reference the actual Chrome executable, not just the application binary
(e.g. "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome").</p>
<p>The binary path be absolute or relative to the chromedriver server
executable, but it must exist on the machine that will launch Chrome.</p>
<div><div class="fn-details"><div><b>Parameters</b></div><dl><dt>path<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd><p>The path to the Chrome binary to use.</p>
</dl></div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="module_selenium-webdriver_chrome_class_Options.html">Options</a></code><dd><p>A self reference.</p>
</dl></div></div></div></div><hr class="fn-sep"><div id="setChromeLogFile" class="function"><div><h3>setChromeLogFile(<wbr>path)<span class="codelink"><a href="source/chrome.js.src.html#l670">code »</a></span></h3><p>Sets the path to Chrome's log file. This path should exist on the machine
that will launch Chrome.</p>
<div><div class="fn-details"><div><b>Parameters</b></div><dl><dt>path<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd><p>Path to the log file to use.</p>
</dl></div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="module_selenium-webdriver_chrome_class_Options.html">Options</a></code><dd><p>A self reference.</p>
</dl></div></div></div></div><hr class="fn-sep"><div id="setChromeMinidumpPath" class="function"><div><h3>setChromeMinidumpPath(<wbr>path)<span class="codelink"><a href="source/chrome.js.src.html#l682">code »</a></span></h3><p>Sets the directory to store Chrome minidumps in. This option is only
supported when ChromeDriver is running on Linux.</p>
<div><div class="fn-details"><div><b>Parameters</b></div><dl><dt>path<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd><p>The directory path.</p>
</dl></div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="module_selenium-webdriver_chrome_class_Options.html">Options</a></code><dd><p>A self reference.</p>
</dl></div></div></div></div><hr class="fn-sep"><div id="setLocalState" class="function"><div><h3>setLocalState(<wbr>state)<span class="codelink"><a href="source/chrome.js.src.html#l578">code »</a></span></h3><p>Sets preferences for the "Local State" file in Chrome's user data
directory.</p>
<div><div class="fn-details"><div><b>Parameters</b></div><dl><dt>state<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a></code><dd><p>Dictionary of local state preferences.</p>
</dl></div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="module_selenium-webdriver_chrome_class_Options.html">Options</a></code><dd><p>A self reference.</p>
</dl></div></div></div></div><hr class="fn-sep"><div id="setLoggingPrefs" class="function"><div><h3>setLoggingPrefs(<wbr>prefs)<span class="codelink"><a href="source/chrome.js.src.html#l536">code »</a></span></h3><p>Sets the logging preferences for the new session.</p>
<div><div class="fn-details"><div><b>Parameters</b></div><dl><dt>prefs<code><a href="class_webdriver_logging_Preferences.html">webdriver.logging.Preferences</a></code><dd><p>The logging preferences.</p>
</dl></div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="module_selenium-webdriver_chrome_class_Options.html">Options</a></code><dd><p>A self reference.</p>
</dl></div></div></div></div><hr class="fn-sep"><div id="setMobileEmulation" class="function"><div><h3>setMobileEmulation(<wbr>config)<span class="codelink"><a href="source/chrome.js.src.html#l724">code »</a></span></h3><p>Configures Chrome to emulate a mobile device. For more information, refer to
the ChromeDriver project page on <a href="https://sites.google.com/a/chromium.org/chromedriver/mobile-emulation">mobile emulation</a>. Configuration
options include:</p>
<ul><li><code>deviceName</code>: The name of a pre-configured <a href="https://developer.chrome.com/devtools/docs/device-mode">emulated device</a></li><li><code>width</code>: screen width, in pixels</li><li><code>height</code>: screen height, in pixels</li><li><code>pixelRatio</code>: screen pixel ratio</li></ul>
<p><strong>Example 1: Using a Pre-configured Device</strong></p>
<pre><code>var options = new chrome.Options().setMobileEmulation(
{deviceName: 'Google Nexus 5'});
var driver = new chrome.Driver(options);
</code></pre>
<p><strong>Example 2: Using Custom Screen Configuration</strong></p>
<pre><code>var options = new chrome.Options().setMobileEmulation({
width: 360,
height: 640,
pixelRatio: 3.0
});
var driver = new chrome.Driver(options);
</code></pre>
<div><div class="fn-details"><div><b>Parameters</b></div><dl><dt>config<code>?({deviceName: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>}|{height: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>, pixelRatio: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>, width: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>})</code><dd><p>The
mobile emulation configuration, or <code>null</code> to disable emulation.</p>
</dl></div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="module_selenium-webdriver_chrome_class_Options.html">Options</a></code><dd><p>A self reference.</p>
</dl></div></div></div></div><hr class="fn-sep"><div id="setPerfLoggingPrefs" class="function"><div><h3>setPerfLoggingPrefs(<wbr>prefs)<span class="codelink"><a href="source/chrome.js.src.html#l566">code »</a></span></h3><p>Sets the performance logging preferences. Options include:</p>
<ul><li><code>enableNetwork</code>: Whether or not to collect events from Network domain.</li><li><code>enablePage</code>: Whether or not to collect events from Page domain.</li><li><code>enableTimeline</code>: Whether or not to collect events from Timeline domain.
Note: when tracing is enabled, Timeline domain is implicitly disabled,
unless <code>enableTimeline</code> is explicitly set to true.</li><li><code>tracingCategories</code>: A comma-separated string of Chrome tracing categories
for which trace events should be collected. An unspecified or empty
string disables tracing.</li><li><code>bufferUsageReportingInterval</code>: The requested number of milliseconds
between DevTools trace buffer usage events. For example, if 1000, then
once per second, DevTools will report how full the trace buffer is. If a
report indicates the buffer usage is 100%, a warning will be issued.</li></ul>
<div><div class="fn-details"><div><b>Parameters</b></div><dl><dt>prefs<code>{bufferUsageReportingInterval: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>, enableNetwork: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a>, enablePage: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a>, enableTimeline: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a>, tracingCategories: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>}</code><dd><p>The performance
logging preferences.</p>
</dl></div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="module_selenium-webdriver_chrome_class_Options.html">Options</a></code><dd><p>A self reference.</p>
</dl></div></div></div></div><hr class="fn-sep"><div id="setProxy" class="function"><div><h3>setProxy(<wbr>proxy)<span class="codelink"><a href="source/chrome.js.src.html#l735">code »</a></span></h3><p>Sets the proxy settings for the new session.</p>
<div><div class="fn-details"><div><b>Parameters</b></div><dl><dt>proxy<code><a href="module_selenium-webdriver.html">selenium-webdriver.ProxyConfig</a></code><dd><p>The proxy configuration to use.</p>
</dl></div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="module_selenium-webdriver_chrome_class_Options.html">Options</a></code><dd><p>A self reference.</p>
</dl></div></div></div></div><hr class="fn-sep"><div id="setUserPreferences" class="function"><div><h3>setUserPreferences(<wbr>prefs)<span class="codelink"><a href="source/chrome.js.src.html#l525">code »</a></span></h3><p>Sets the user preferences for Chrome's user profile. See the "Preferences"
file in Chrome's user data directory for examples.</p>
<div><div class="fn-details"><div><b>Parameters</b></div><dl><dt>prefs<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a></code><dd><p>Dictionary of user preferences to use.</p>
</dl></div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="module_selenium-webdriver_chrome_class_Options.html">Options</a></code><dd><p>A self reference.</p>
</dl></div></div></div></div><hr class="fn-sep"><div id="toCapabilities" class="function"><div><h3>toCapabilities(<wbr>opt_capabilities)<span class="codelink"><a href="source/chrome.js.src.html#l747">code »</a></span></h3><p>Converts this options instance to a <a href="class_webdriver_Capabilities.html"><code>webdriver.Capabilities</code></a> object.</p>
<div><div class="fn-details"><div><b>Parameters</b></div><dl><dt>opt_capabilities<code>?<a href="module_selenium-webdriver_class_Capabilities.html">Capabilities</a>=</code><dd><p>The capabilities to merge
these options into, if any.</p>
</dl></div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="class_webdriver_Capabilities.html">webdriver.Capabilities</a></code><dd><p>The capabilities.</p>
</dl></div></div></div></div><h2>Static Functions</h2><div id="Options.fromCapabilities" class="function"><div><h3>Options.fromCapabilities(<wbr>capabilities)<span class="codelink"><a href="source/chrome.js.src.html#l405">code »</a></span></h3><p>Extracts the ChromeDriver specific options from the given capabilities
object.</p>
<div><div class="fn-details"><div><b>Parameters</b></div><dl><dt>capabilities<code><a href="module_selenium-webdriver_class_Capabilities.html">Capabilities</a></code><dd><p>The capabilities object.</p>
</dl></div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="module_selenium-webdriver_chrome_class_Options.html">Options</a></code><dd><p>The ChromeDriver options.</p>
</dl></div></div></div></div></article><nav><h3><a href="index.html" tabindex="2">Overview</a></h3><div><input type="checkbox" id="nav-modules" checked/><label for="nav-modules"><h3><span class="selectable" tabindex="2">Modules</span></h3></label><div id="nav-modules-view"></div></div><div><input type="checkbox" id="nav-types" checked/><label for="nav-types"><h3><span class="selectable" tabindex="2">Types</span></h3></label><div id="nav-types-view"></div></div><h3><a href="Changes.html" tabindex="2">Changes</a></h3></nav></main><footer><div><a href="https://github.com/jleyba/js-dossier">Generated by dossier</a></div></footer><script src="types.js"></script><script src="dossier.js"></script>