Skip to content

Instantly share code, notes, and snippets.

@nombrekeff
Last active June 29, 2019 05:48
Show Gist options
  • Save nombrekeff/dc2b118ab76e899f3352da717f7306a8 to your computer and use it in GitHub Desktop.
Save nombrekeff/dc2b118ab76e899f3352da717f7306a8 to your computer and use it in GitHub Desktop.
selenium-webdriver .setPreference is not a function
const { Builder } = require('selenium-webdriver'); // Currently using ^3.6.0
const firefox = require('selenium-webdriver/firefox'); // Currently using ^3.6.0
// Create a builder for browser 'firefox'
let builder = new Builder().forBrowser('firefox');
// I then create firefox options
let options = new firefox.Options();
// setPreference is present in the docs as well as the type file for this version
// But is present in this docs: https://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/firefox_exports_Options.html
// will fail: TypeError: options.setPreference is not a function
options.setPreference('lightweightThemes.selectedThemeID', 'default-theme@mozilla.org');
// Then I build it
builder.setFirefoxOptions(options);
builder.build();
// Running it: node test.js
@nombrekeff
Copy link
Author

Setting the profile was as simple as doing:

options.setProfile('/path/to/profile');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment