protractor Protractor Debugger Using browser.pause()


The pause() method is one of the easiest solution Protractor provides you to debug the code, in order to use it you have to add it in your code where you want to pause the execution.Once the execution is in paused state:

  1. You can use C (type C) to move forward. Be careful while using it, you have to write this command without any delay as you might get timeout error from your assertion library if you delayed to press c.

  2. Type repl to enter interactive mode. The interactive mode is used to send browser commands directly to open instance of browser. For example in interactive mode you can issue command like this:

> element(by.css('#username')).getText() 
> NoSuchElementError: No element found using locator: by.username("#username")

Notice output of above command appears directly over there, which lets you know correctness of your command.

Note: If you have opened the Chrome Dev Tools, you must close them before continuing the test because ChromeDriver cannot operate when the Dev Tools are open.

  1. Exit debug mode using CTRL+C, you can take yourself out from debug mode using classical CTRL+C command.
 it('should pause when we use pause method', function () {
    var username = element(by.model('username'));

    var password = element(by.model('password'));
  1. Press d to continue to the next debugger statement