UNPKG

selenium-webdriver

Version:

The official WebDriver JavaScript bindings from the Selenium project

67 lines (64 loc) 5.69 kB
<!DOCTYPE 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 &#61; require(&#39;selenium-webdriver/firefox&#39;); var profile &#61; new firefox.Profile(); profile.addExtension(&#39;/path/to/firebug.xpi&#39;); profile.setPreference(&#39;extensions.firebug.showChromeErrors&#39;, true); var options &#61; new firefox.Options().setProfile(profile); var driver &#61; 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 &#61; new firefox.Profile( &#39;/usr/local/home/bob/.mozilla/firefox/3fgog75h.testing&#39;); var options &#61; new firefox.Options().setProfile(profile); var driver &#61; 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 &#61; require(&#39;selenium-webdriver/firefox&#39;); var binary &#61; new firefox.Binary(&#39;/my/firefox/install/dir/firefox-bin&#39;); var options &#61; new firefox.Options().setBinary(binary); var driver &#61; 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&#39;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 &#61; new firefox.Options() .setProfile(&#39;/profile/path/on/remote/host&#39;) .setBinary(&#39;/install/dir/on/remote/host/firefox-bin&#39;); var driver &#61; new (require(&#39;selenium-webdriver&#39;)).Builder() .forBrowser(&#39;firefox&#39;) .usingServer(&#39;http://127.0.0.1:4444/wd/hub&#39;) .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>