diff --git a/lib/protractor.js b/lib/protractor.js index 2ce52faa9..4535dc5be 100644 --- a/lib/protractor.js +++ b/lib/protractor.js @@ -1120,8 +1120,10 @@ Protractor.prototype.debugger = function() { * browser.pause() in your test to enter the protractor debugger from that * point in the control flow. * Does not require changes to the command line (no need to add 'debug'). + * + * @param {=number} opt_debugPort Optional port to use for the debugging process */ -Protractor.prototype.pause = function() { +Protractor.prototype.pause = function(opt_debugPort) { // Patch in a function to help us visualize what's going on in the control // flow. webdriver.promise.ControlFlow.prototype.getControlFlowText = function() { @@ -1171,6 +1173,10 @@ Protractor.prototype.pause = function() { return asString; }; + if (opt_debugPort) { + process.debugPort = opt_debugPort; + } + // Call this private function instead of sending SIGUSR1 because Windows. process._debugProcess(process.pid); var flow = webdriver.promise.controlFlow(); @@ -1179,7 +1185,7 @@ Protractor.prototype.pause = function() { console.log('Starting WebDriver debugger in a child process. Pause is ' + 'still beta, please report issues at github.com/angular/protractor'); var nodedebug = require('child_process'). - fork(__dirname + '/wddebugger.js', ['localhost:5858']); + fork(__dirname + '/wddebugger.js', [process.debugPort]); process.on('exit', function() { nodedebug.kill('SIGTERM'); }); diff --git a/lib/wddebugger.js b/lib/wddebugger.js index 6e42625d7..a348d0cea 100644 --- a/lib/wddebugger.js +++ b/lib/wddebugger.js @@ -17,6 +17,9 @@ var client = new baseDebugger.Client(); var host = 'localhost'; var port = 5858; +if (process.argv[2]) { + port = process.argv[2]; +} var debuggerRepl; var resumeReplCallback = null;