Protractor: Debug not working in Protractor

Created on 14 Aug 2014  ·  3Comments  ·  Source: angular/protractor

I've taken a look through past issues, and to the best of my knowledge, it does not appear to be addressed (these issues appear similar, but all seem to be closed):

  • #907
  • #552 (Which has further discussion of the problem existing despite being closed)

Version Information:

  • Mac 10.9.4
  • Node 0.10.30
  • Protractor 1.0.0
  • Coffeescript 1.7.1

Steps to reproduce:

  • Create the following protractor config (e2e.conf.coffee):
    Copied from https://github.com/angular/protractor/blob/master/docs/referenceConf.js
    exports.config =
      seleniumServerJar: null
      seleniumPort: null
      seleniumArgs: []
      chromeOnly: true
      seleniumAddress: null
      sauceUser: null
      sauceKey: null
      sauceSeleniumAddress: null

      specs: ["e2e/*.coffee"]
      exclude: []
      capabilities:
        browserName: "chrome"
        count: 1
        shardTestFiles: false
        maxInstances: 1

      multiCapabilities: []
      maxSessions: -1
      baseUrl: "http://localhost:8081"
      rootElement: "body"
      allScriptsTimeout: 11000
      getPageTimeout: 10000
      framework: "jasmine"

      jasmineNodeOpts:
        isVerbose: true
        showColors: true
        includeStackTrace: true
        defaultTimeoutInterval: 30000
  • Create the following spec in e2e/spec.coffee
    describe 'Page', () ->
      it 'should debug properly', () ->
        browser.get '/'

        x = 'There is only X'
        y = 1
        z = ++y
        browser.debugger()
  • Run the following command: protractor debug e2e.conf.coffee

Expected Result:

  • The break point is set at the correct location
  • Variables in the local scope are accessible when entering repl mode and accessing a variable

Results:
Breakpoint is set in timers.js, and can't access any variables in scope other than browser:

protractor debug src/test/e2e.conf.coffee
Using ChromeDriver directly...
Hit SIGUSR1 - starting debugger agent.
debugger listening on port 5858
connecting... ok
break in timers.js:79
  77 }
  78
  79 function listOnTimeout() {
  80   var msecs = this.msecs;
  81   var list = this;
debug> repl
Press Ctrl + C to leave debug repl
> x
ReferenceError: x is not defined
> y
ReferenceError: y is not defined
> z
ReferenceError: z is not defined
> browser
{ controlFlow: [Function],
  schedule: [Function],
  getSession: [Function],
  getCapabilities: [Function],
  quit: [Function],
  ...
}
question

Most helpful comment

what the heck is the point of the above browser.debugger() mode then? If not to debug your test...

All 3 comments

I understand why this confusing, but this is actually working as intended. browser.debugger pauses outside of the scope of your it block, so x, y, and z are in fact not expected to be defined.

The reason that browser.debugger is exposed is precisely because we don't want to set a breakpoint inside the it block - we want to set it on the control flow in-between when the commands execute.

You can still use good old debugger and run with the --debug flag to actually pause within the it block.

Using good old debugger and running protractor with the --debug flag doesn't pause execution at all for me. :-/

what the heck is the point of the above browser.debugger() mode then? If not to debug your test...

Was this page helpful?
0 / 5 - 0 ratings