WebDriverJS: Setting the binary


WebDriverJS uses the default browser binary (or executable) to initialize a driver.

setBinary

To initialize a browser with a different binary, use Options setBinary.

The following example builds a FirefoxDriver with a specified binary:

const { Builder } = require('selenium-webdriver');
const { Options } = require('selenium-webdriver/firefox');

// replace `path/to/binary` with your binary path
const options = new Options().setBinary('path/to/binary');

const driver = new Builder()
  .forBrowser('firefox')
  .setFirefoxOptions(options)
  .build();

driver.start();

This is useful if you installed multiple browser executables and wanted to specify an executable.

Code

Check out the Gist for the full example:

For more information on Selenium for Node.js, check out my post WebDriverJS: Launch a browser.



Please support this site and join our Discord!