Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

Commit ef61662

Browse files
committed
feat(runner): allow bypassing the selenium standalone server if running only chr
Using the config option `chromeOnly` now enables running ChromeDriver directly, without going through the Selenium Standalone. The chromedriver binary should be available in your PATH, or should be specified with the config option `chromeDriver`.
2 parents a24eeee + 35fa7d7 commit ef61662

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

lib/runner.js

+15-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ var path = require('path')
33
var fs = require('fs');
44
var webdriver = require('selenium-webdriver');
55
var remote = require('selenium-webdriver/remote');
6+
var chrome = require('selenium-webdriver/chrome');
67
var minijn = require('minijasminenode');
78
var protractor = require('./protractor.js');
89
var SauceLabs = require('saucelabs');
@@ -110,7 +111,10 @@ var setUpSelenium = function() {
110111
});
111112
}
112113

113-
if (config.seleniumAddress) {
114+
if (config.chromeOnly) {
115+
util.puts('Using ChromeDriver directly...');
116+
deferred.fulfill(null);
117+
} else if (config.seleniumAddress) {
114118
util.puts('Using the selenium server at ' + config.seleniumAddress);
115119
deferred.fulfill(config.seleniumAddress);
116120
} else if (sauceAccount) {
@@ -195,9 +199,16 @@ var runJasmineTests = function() {
195199
// TODO: This should not be tied to the webdriver promise loop, it should use
196200
// another promise system instead.
197201
var runDeferred = webdriver.promise.defer();
198-
driver = new webdriver.Builder().
199-
usingServer(config.seleniumAddress).
200-
withCapabilities(config.capabilities).build();
202+
203+
if (config.chromeOnly) {
204+
var service = new chrome.ServiceBuilder(config.chromeDriver).build();
205+
driver = chrome.createDriver(
206+
new webdriver.Capabilities(config.capabilities), service);
207+
} else {
208+
driver = new webdriver.Builder().
209+
usingServer(config.seleniumAddress).
210+
withCapabilities(config.capabilities).build();
211+
}
201212

202213
driver.getSession().then(function(session) {
203214
driver.manage().timeouts().setScriptTimeout(config.allScriptsTimeout);

referenceConf.js

+7
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ exports.config = {
99
// 2. seleniumAddress - to connect to a Selenium server which is already
1010
// running.
1111
// 3. sauceUser/sauceKey - to use remote Selenium servers via SauceLabs.
12+
//
13+
// If the chromeOnly option is specified, no Selenium server will be started,
14+
// and chromeDriver will be used directly (from the location specified in
15+
// chromeDriver)
1216

1317
// The location of the selenium standalone server .jar file.
1418
seleniumServerJar: './selenium/selenium-server-standalone-2.37.0.jar',
@@ -20,6 +24,9 @@ exports.config = {
2024
// the system property webdriver.chrome.driver. If null, selenium will
2125
// attempt to find chromedriver using PATH.
2226
chromeDriver: './selenium/chromedriver',
27+
// If true, only chromedriver will be started, not a standalone selenium.
28+
// Tests for browsers other than chrome will not run.
29+
chromeOnly: false,
2330
// Additional command line options to pass to selenium. For example,
2431
// if you need to change the browser timeout, use
2532
// seleniumArgs: ['-browserTimeout=60'],

0 commit comments

Comments
 (0)