
以下对我有用:
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")我已经使用各种值测试了上面的代码,并发现它可以工作。
如果要查看可以对该
Options对象执行的其他 *** 作,可以打开
node_modules/selenium_webdriver/chrome.js并阅读源代码。这就是我找出上述方法的方式。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)