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:
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.
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.
CTRL+C
, you can take yourself out from debug mode using classical CTRL+C command. it('should pause when we use pause method', function () {
browser.get('/index.html');
var username = element(by.model('username'));
username.sendKeys('username');
browser.pause();
var password = element(by.model('password'));
password.sendKeys('password');
browser.pause();
});