Debugging Protractor Tests

This post is part of a ten-part series on how to write better Protractor tests. You can find the rest of the series here.

There are two types of debugging you can do in your Protractor tests:

  • browser.pause()
  • browser.debugger()

Use browser.pause() wherever you want to pause:

Once Protractor pauses you can issue commands. For instance:

  • Use c to move forward
  • Use repl to enter interactive mode
  • Use ctrl-C to exit and continue test

Use browser.debugger() if you want to use the node debugger

Note that in order to use the debugger you need to start Protractor with the debug option:

If you don’t know which to use, you probably want browser.pause(), but try them both.

WARNING: One thing to note, is that the debugger doesn’t work if you have multiple Protractors running. E.g. if you have, say, an elementExplorer running in another tab, the debugger won’t be able to connect and you will see that Protractor doesn’t pause when you expect it to.

The solution is either 1. change the debugging port or 2. quit the other Protractor instances.

Learn Protractor in a few hours with our online course

Protractor is a one of the best ways to ensure your app is working correctly because you can write code that acts like a real user. But Protractor can also be confusing and difficult to work with when you're just starting out. We've put together an online course that will help you become a master at Protractor.

You'll save tons of time and frustration learning Protractor because we've worked out everything you need to know. Become a Protractor testing master today!