...is an end-to-end test framework for Angular and AngularJS applications. Protractor runs tests against your application running in a real browser, interacting with it as a user would.
End-to-End Testing is defined as a type Software Testing that not only validates the software system under test but also checks its integration with external interfaces. Hence, the name "End-to-End". The purpose of End-to-End Testing is to exercise a complete production-like scenario.
To achieve the most flexible set functionality, it’s common to use a combination of several tools.
General Prominent Testing Tools
Unit and Integration Tests Frameworks
Functional Testing Tools
Group your e2e tests in a structure that makes sense to the structure of your project
|-- test
|-- unit
|-- e2e
|-- page-objects
home-page.js
profile-page.js
contacts-page.js
home-spec.js
profile-spec.js
contacts-spec.js
...simply models pages as objects within the test code.
example.page-object.ts
import { browser, by, element, ElementFinder } from 'protractor';
export class ExamplePageObject extends BasePageObject {
public async navigateToPage(): Promise {
return super.navigateTo('/example-page');
}
public getExampleButton(): ElementFinder {
return element(by.css('.example-button'));
}
// more methods...
}
example.spec.ts
import { ExamplePageObject } from '@pos/example.page-object';
describe('Example test suite', async () => {
let examplePO: ExamplePageObject;
beforeAll(async () => {
examplePO = new ExamplePageObject();
await examplePO.navigateToPage();
});
it('shold navigate to example page', async () => {
expect(await examplePO.isPageOpened()).toBe(true, 'comment');
});
}
Chrome configuration example
capabilities: {
browserName: 'chrome',
maxInstances: 3,
chromeOptions: {
args: ['--headless', '--window-size=1920,1080'],
prefs: {
download: {
default_directory: require('path').join(__dirname, '../..', 'data-file'),
directory_upgrade: true
},
safebrowsing: {
enabled: true
}
}
}
}
};
Green console
vs
Red console
#presentation_link