1
1
var baseDebugger = require ( '_debugger' ) ;
2
+ var path = require ( 'path' ) ;
2
3
3
4
/**
4
5
* Create a debugger client and attach to a running protractor process.
@@ -34,11 +35,13 @@ exports.attachDebugger = function(pid, opt_port) {
34
35
35
36
/**
36
37
* Set a breakpoint for evaluating REPL statements.
38
+ * This sets a breakpoint in Protractor's breakpointhook.js, so that we'll
39
+ * break after executing a command from the REPL.
37
40
*/
38
41
exports . setEvaluateBreakpoint = function ( client , cb ) {
39
42
client . setBreakpoint ( {
40
43
type : 'scriptRegExp' ,
41
- target : 'built/ breakpointhook\ .js' , //jshint ignore:line
44
+ target : prepareDebuggerPath ( 'built' , ' breakpointhook.js') ,
42
45
line : 2
43
46
} , function ( err , response ) {
44
47
if ( err ) {
@@ -50,11 +53,18 @@ exports.setEvaluateBreakpoint = function(client, cb) {
50
53
51
54
/**
52
55
* Set a breakpoint for moving forward by one webdriver command.
56
+ * This sets a breakpoint in selenium-webdriver/lib/http.js, and is
57
+ * extremely sensitive to the selenium version. It works for
58
+ * selenium-webdriver 3.0.1
59
+ * This breaks on the following line in http.js:
60
+ * let request = buildRequest(this.customCommands_, this.w3c, command);
61
+ * And will need to break at a similar point in future selenium-webdriver
62
+ * versions.
53
63
*/
54
64
exports . setWebDriverCommandBreakpoint = function ( client , cb ) {
55
65
client . setBreakpoint ( {
56
66
type : 'scriptRegExp' ,
57
- target : 'lib/ http\ .js' , //jshint ignore:line
67
+ target : prepareDebuggerPath ( 'lib' , ' http.js') ,
58
68
line : 433
59
69
} , function ( err , response ) {
60
70
if ( err ) {
@@ -64,6 +74,15 @@ exports.setWebDriverCommandBreakpoint = function(client, cb) {
64
74
} ) ;
65
75
} ;
66
76
77
+ /**
78
+ * Create a cross-platform friendly path for setting scriptRegExp breakpoints.
79
+ */
80
+ function prepareDebuggerPath ( ...parts ) {
81
+ return path . join ( ...parts )
82
+ . replace ( '\\' , '\\\\' )
83
+ . replace ( '.' , '\\.' ) ;
84
+ }
85
+
67
86
/**
68
87
* Trim excess symbols from the repl command so that it is consistent with
69
88
* the user input.
0 commit comments