Reputation: 638
I have been searching the internet for hours trying to find a way of being able to debug some e2e tests that I have written on protractor for my Angular 2 recipe app (the tests exist in a spec file - login.e2e-spec.ts).
I want to be able to put break points in my code and step through each line of code in my spec files.
I have node 8.x.x installed on my machine therefore I can no longer using the browser.pause function.
Does anybody know how to successfully debug protractor spec files by stepping through each line at a time using break points?
Below is my test spec code:-
import { LoginPage } from './login.po';
import { CommonPage } from '../common/common.po';
import { Navigation } from 'selenium-webdriver';
import { browser } from 'protractor';
describe('angular-two-recipe-app App Login', () => {
let loginPage: LoginPage;
let commonPage: CommonPage;
beforeEach(() => {
loginPage = new LoginPage();
commonPage = new CommonPage();
});
it('should successfully display the login page', async () => {
//debugger;
loginPage.navigateTo();
browser.debugger();
browser.manage().window().setSize(1680, 1050);
expect(loginPage.getUsernameInputBox()).toBeTruthy();
expect(loginPage.getPasswordInputBox()).toBeTruthy();
expect(loginPage.getSubmitButton()).toBeTruthy();
expect(loginPage.getUsernameInputBoxValue()).toBe('');
expect(loginPage.getPasswordInputBoxValue()).toBe('');
});
});
Upvotes: 2
Views: 3029
Reputation: 408
The protractor API has a debugger method you can use. http://www.protractortest.org/#/api?view=ProtractorBrowser.prototype.debugger
For example:
it('clicks a link', async () => {
await element(by.css('#link')).click();
browser.debugger();
// ...some other action
});
Upvotes: 3