ChromeOptions causes reference error using Selenium ChromeDriver for node.js
The following works for me:
var webdriver = require("selenium-webdriver");
var chrome = require("selenium-webdriver/chrome");
// Make sure the PATH is set to find ChromeDriver. I'm on a Unix
// system. You'll need to adapt to whatever is needed for
// Windows. Actually, since you say that you can get a browser to show
// up if you don't try to specify options, your ChromeDriver is
// probably already on your PATH, so you can probably skip this.
process.env["PATH"] += ":/home/user/src/selenium/";
var options = new chrome.Options();
// Commented out because they are obviously not what you want.
// Uncomment and adapt as needed:
//
// options.setChromeBinaryPath("/tmp/foo");
// options.addArguments(["--blah"]);
var driver = new webdriver.Builder().
withCapabilities(options.toCapabilities()).build();
driver.get("http://www.google.com")
I've tested the code above with various values and found that it works.
If you want to see what else you can do with the Options
object, you can open node_modules/selenium_webdriver/chrome.js
and read the source. This is how I figured out the above method.