protractor Getting started with protractor First test using Protractor


Example

Protractor needs only two files to run the first test, spec (test code) file and configuration file. The spec file contains test code and the other one contains configuration details like spec file path, browser details, test url, framework parameters etc. To write first test we will be providing only selenium server address and spec file path.The other parameters like browser, timeout, framework will be picked up to default values.

The default browser for Protractor is Chrome.

conf.js - Configuration file

exports.config = {
  seleniumAddress: 'http://localhost:4444/wd/hub',
  specs: ['spec.js']
};

spec.js - Spec (test code) file

describe('first test in protractor', function() {
  it('should verify title', function() {
    browser.get('https://angularjs.org');

    expect(browser.getTitle()).toEqual('AngularJS — Superheroic JavaScript MVW Framework');
  });
});

seleniumAddress - Path to the server where webdriver server is running .

specs - An array element which contains path of test files. The multiple paths can be specified by comma separated values.

describe - Syntax from Jasmine framework. describe syntax sta