WebDriverJS: Setting the binary

Is it possible to build a WebDriver using a browser that’s not installed in its default location?

You can by setting the binary.

This is useful if you want to use a different version or executable of a browser.

Here’s how it’s done for Firefox with the WebDriverJS API:

// set-binary-driver.js

var webdriver = require('selenium-webdriver');
var firefox = require('selenium-webdriver/firefox');
var builder = new webdriver.Builder().forBrowser('firefox');

// path to binary
var binaryPath = '/path/to/firefox/binary';
  new firefox.Options().setBinary(binaryPath)

If you’re not familiar with Selenium for Node.js, check out my post WebDriverJS: Launch a browser.

This can be done for browsers like Chrome, IE, Opera, and PhantomJS since WebDriverJS allows us to configure the driver options.

See complete example: