diff --git a/lib/debugger/debuggerCommons.js b/lib/debugger/debuggerCommons.js index 7575fb20f..6da09d583 100644 --- a/lib/debugger/debuggerCommons.js +++ b/lib/debugger/debuggerCommons.js @@ -1,4 +1,5 @@ var baseDebugger = require('_debugger'); +var path = require('path'); /** * Create a debugger client and attach to a running protractor process. @@ -34,11 +35,13 @@ exports.attachDebugger = function(pid, opt_port) { /** * Set a breakpoint for evaluating REPL statements. + * This sets a breakpoint in Protractor's breakpointhook.js, so that we'll + * break after executing a command from the REPL. */ exports.setEvaluateBreakpoint = function(client, cb) { client.setBreakpoint({ type: 'scriptRegExp', - target: 'built/breakpointhook\.js', //jshint ignore:line + target: prepareDebuggerPath('built', 'breakpointhook.js'), line: 2 }, function(err, response) { if (err) { @@ -50,11 +53,18 @@ exports.setEvaluateBreakpoint = function(client, cb) { /** * Set a breakpoint for moving forward by one webdriver command. + * This sets a breakpoint in selenium-webdriver/lib/http.js, and is + * extremely sensitive to the selenium version. It works for + * selenium-webdriver 3.0.1 + * This breaks on the following line in http.js: + * let request = buildRequest(this.customCommands_, this.w3c, command); + * And will need to break at a similar point in future selenium-webdriver + * versions. */ exports.setWebDriverCommandBreakpoint = function(client, cb) { client.setBreakpoint({ type: 'scriptRegExp', - target: 'lib/http\.js', //jshint ignore:line + target: prepareDebuggerPath('lib', 'http.js'), line: 433 }, function(err, response) { if (err) { @@ -64,6 +74,15 @@ exports.setWebDriverCommandBreakpoint = function(client, cb) { }); }; +/** + * Create a cross-platform friendly path for setting scriptRegExp breakpoints. + */ +function prepareDebuggerPath(...parts) { + return path.join(...parts) + .replace('\\', '\\\\') + .replace('.', '\\.'); +} + /** * Trim excess symbols from the repl command so that it is consistent with * the user input.