Skip to content

Commit daf0539

Browse files
committed
[js] Instead of always writing to a file in the current working directory,
which may not be writable, add a parameter to the phantomjs.Driver constructor to configure the path to the desired log file. Still todo: add an Options class so phantomjs configuration is consistent with the other drivers. Fixes #1244
1 parent cc27bb1 commit daf0539

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

javascript/node/selenium-webdriver/CHANGES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
module to break a circular dependency.
2424
* FIXED: `io.findInPath()` will no longer match against directories that have
2525
the same basename as the target file.
26+
* FIXED: `phantomjs.Driver` now takes a third argument that defines the path to
27+
a log file to use for the phantomjs executable's output. This may be quickly
28+
set at runtime with the `SELENIUM_PHANTOMJS_LOG` environment variable.
2629

2730
### Changes for W3C WebDriver Spec Compliance
2831

javascript/node/selenium-webdriver/phantomjs.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,6 @@ const BINARY_PATH_CAPABILITY = 'phantomjs.binary.path';
5656
const CLI_ARGS_CAPABILITY = 'phantomjs.cli.args';
5757

5858

59-
/**
60-
* Default log file to use if one is not specified through CLI args.
61-
* @type {string}
62-
* @const
63-
*/
64-
const DEFAULT_LOG_FILE = 'phantomjsdriver.log';
65-
66-
6759
/**
6860
* Custom command names supported by PhantomJS.
6961
* @enum {string}
@@ -136,11 +128,16 @@ class Driver extends webdriver.WebDriver {
136128
* capabilities.
137129
* @param {promise.ControlFlow=} opt_flow The control flow to use,
138130
* or {@code null} to use the currently active flow.
131+
* @param {string=} opt_logFile Path to the log file for the phantomjs
132+
* executable's output. For convenience, this may be set at runtime with
133+
* the `SELENIUM_PHANTOMJS_LOG` environment variable.
139134
*/
140-
constructor(opt_capabilities, opt_flow) {
135+
constructor(opt_capabilities, opt_flow, opt_logFile) {
136+
// TODO: add an Options class for consistency with the other driver types.
137+
141138
var caps = opt_capabilities || capabilities.Capabilities.phantomjs();
142139
var exe = findExecutable(caps.get(BINARY_PATH_CAPABILITY));
143-
var args = ['--webdriver-logfile=' + DEFAULT_LOG_FILE];
140+
var args = [];
144141

145142
var logPrefs = caps.get(capabilities.Capability.LOGGING_PREFS);
146143
if (logPrefs instanceof logging.Preferences) {
@@ -155,6 +152,11 @@ class Driver extends webdriver.WebDriver {
155152
}
156153
}
157154

155+
opt_logFile = process.env['SELENIUM_PHANTOMJS_LOG'] || opt_logFile;
156+
if (typeof opt_logFile === 'string') {
157+
args.push('--webdriver-logfile=' + opt_logFile);
158+
}
159+
158160
var proxy = caps.get(capabilities.Capability.PROXY);
159161
if (proxy) {
160162
switch (proxy.proxyType) {

0 commit comments

Comments
 (0)