Install Protractor globally using the command *npm install protractor –g or use the command *npm install protractor for a particular project.
To check if you have correctly installed it, use the command *protractor --version
Protractor installs Selenium webdriver manager with it, update Selenium webdriver manager with command webdriver-manager update.
To run,
- clone the project
- npm i : install dependancies
- npm run update-server : update the webdriver-manageer
- npm run start-server : start webdriver-manager
- npm run test : to run test (executes in Chrome browser) for multi browser: npm run multi-browser : executes in Chrome and Firefox browser
Create a test named folder in your project directory. Create Config file conf.js to define two things in it:
seleniumAddress: Address of Selenium webdriver manager.
specs: Our test case file, which should be run.
So our conf.js would look something like this:
SomeNameconf.js
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['spec.js']
};
Can be configured to run against multiple browsers
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['spec.js'],
multiCapabilities: [{
browser: 'chrome'
}, {
browser: 'firefox'
}]
};