selenium-webdriver
Version:
The official WebDriver JavaScript bindings from the Selenium project
67 lines (64 loc) • 5.69 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>selenium-webdriver/firefox</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="codelink"><a href="source/firefox/index.js.src.html#l95">View Source</a></div><h1>module selenium-webdriver/firefox</h1><p>Defines the <a href="module_selenium-webdriver_firefox_class_Driver.html">WebDriver</a> client for Firefox.
Each FirefoxDriver instance will be created with an anonymous profile,
ensuring browser historys do not share session data (cookies, history, cache,
offline storage, etc.)</p>
<p><strong>Customizing the Firefox Profile</strong></p>
<p>The <a href="module_selenium-webdriver_firefox_class_Profile.html"><code>Profile</code></a> class may be used to configure the browser profile used
with WebDriver, with functions to install additional
<a href="module_selenium-webdriver_firefox_class_Profile.html#addExtension">extensions</a>, configure browser
<a href="module_selenium-webdriver_firefox_class_Profile.html#setPreference">preferences</a>, and more. For example, you
may wish to include Firebug:</p>
<pre><code>var firefox = require('selenium-webdriver/firefox');
var profile = new firefox.Profile();
profile.addExtension('/path/to/firebug.xpi');
profile.setPreference('extensions.firebug.showChromeErrors', true);
var options = new firefox.Options().setProfile(profile);
var driver = new firefox.Driver(options);
</code></pre>
<p>The <a href="module_selenium-webdriver_firefox_class_Profile.html"><code>Profile</code></a> class may also be used to configure WebDriver based on a
pre-existing browser profile:</p>
<pre><code>var profile = new firefox.Profile(
'/usr/local/home/bob/.mozilla/firefox/3fgog75h.testing');
var options = new firefox.Options().setProfile(profile);
var driver = new firefox.Driver(options);
</code></pre>
<p>The FirefoxDriver will <em>never</em> modify a pre-existing profile; instead it will
create a copy for it to modify. By extension, there are certain browser
preferences that are required for WebDriver to function properly and they
will always be overwritten.</p>
<p><strong>Using a Custom Firefox Binary</strong></p>
<p>On Windows and OSX, the FirefoxDriver will search for Firefox in its
default installation location:</p>
<ul><li>Windows: C:\Program Files and C:\Program Files (x86).</li><li>Mac OS X: /Applications/Firefox.app</li></ul>
<p>For Linux, Firefox will be located on the PATH: <code>$(where firefox)</code>.</p>
<p>You can configure WebDriver to start use a custom Firefox installation with
the <a href="module_selenium-webdriver_firefox_class_Binary.html"><code>Binary</code></a> class:</p>
<pre><code>var firefox = require('selenium-webdriver/firefox');
var binary = new firefox.Binary('/my/firefox/install/dir/firefox-bin');
var options = new firefox.Options().setBinary(binary);
var driver = new firefox.Driver(options);
</code></pre>
<p><strong>Remote Testing</strong></p>
<p>You may customize the Firefox binary and profile when running against a
remote Selenium server. Your custom profile will be packaged as a zip and
transfered to the remote host for use. The profile will be transferred
<em>once for each new session</em>. The performance impact should be minimal if
you've only configured a few extra browser preferences. If you have a large
profile with several extensions, you should consider installing it on the
remote host and defining its path via the <a href="module_selenium-webdriver_firefox_class_Options.html"><code>Options</code></a> class. Custom
binaries are never copied to remote machines and must be referenced by
installation path.</p>
<pre><code>var options = new firefox.Options()
.setProfile('/profile/path/on/remote/host')
.setBinary('/install/dir/on/remote/host/firefox-bin');
var driver = new (require('selenium-webdriver')).Builder()
.forBrowser('firefox')
.usingServer('http://127.0.0.1:4444/wd/hub')
.setFirefoxOptions(options)
.build();
</code></pre>
<h2>Types</h2><dl><dt><a href="module_selenium-webdriver_firefox_class_Binary.html">Binary</a><dd><p>Manages a Firefox subprocess configured for use with WebDriver.</p>
<dt><a href="module_selenium-webdriver_firefox_class_Driver.html">Driver</a><dd><p>A WebDriver client for Firefox.</p>
<dt><a href="module_selenium-webdriver_firefox_class_Options.html">Options</a><dd><p>Configuration options for the FirefoxDriver.</p>
<dt><a href="module_selenium-webdriver_firefox_class_Profile.html">Profile</a><dd><p>Models a Firefox proifle directory for use with the FirefoxDriver.</p>
</dl></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>