DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
The Latest "Software Integration: The Intersection of APIs, Microservices, and Cloud-Based Systems" Trend Report
Get the report
  1. DZone
  2. Data Engineering
  3. Databases
  4. Basic ProtractorJS Setup Along With Report Generation Using jasmine

Basic ProtractorJS Setup Along With Report Generation Using jasmine

Protractor is an open-source E2E testing tool for Angular based applications. Read on to learn how to install it, and use it report generation functionality.

Sibu Stephen user avatar by
Sibu Stephen
·
May. 19, 17 · Tutorial
Like (3)
Save
Tweet
Share
10.27K Views

Join the DZone community and get the full member experience.

Join For Free

Basic Setup for ProtractorJS

In order to install the protractor suite (in any Linux distribution as well as Mac) type the following commands on your terminal:

  1. Make sure you have your npm installed on your machine. If it's not installed us the  sudo apt-get install npm command and install the nvm for package management (version management).

  2.  npm install karma 

  3.  npm install karma-chrome-launcher  (Chrome specific).

  4.  npm install karma-jasmine  (Make sure you install the latest version).

  5.  npm install protractor-jasmine2-screenshot-reporte  (For Reports). 

Next, you will need to update the web-driver manager because it's the back-end server wherein the request passes through the Selenium driver. For that, type the following commands.

./node_modules/protractor/bin/webdriver-manager update.  

Once you've done this, type protractor conf.js from your base directory where conf.js is present.

Configuration Settings to Run Protractor

The following is the basic pattern for conf.js

// Require protractor-jasmine2-screenshot-reporter to generate reports.
var HtmlReporter = require('protractor-jasmine2-screenshot-reporter');

// Provide destination and filename where protractor-reports will be stored.
var reporter = new HtmlReporter({
    dest: 'protractor-reports',
    filename: 'protractor-report.html'
});


// Connecting directing to the conf file
exports.config = {
    directConnect: true,

    // Capabilities to be passed to the webdriver instance.
    capabilities: {
        'browserName': 'chrome',
        //'phantomjs.binary.path': './node_modules/phantomjs/bin/phantomjs'
    },

    // Framework to use. Jasmine is recommended.
    framework: 'jasmine2',

    // Spec patterns are relative to the current working directory when protractor is called.
    specs: ['checklist/checklist-spec.js'],

    // Options to be passed to Jasmine.
    jasmineNodeOpts: {
        defaultTimeoutInterval: 170000
    },

    //Before launch function to run initial configurations before start running the test
    beforeLaunch: function() {
        return new Promise(function(resolve) {
            reporter.beforeLaunch(resolve);
        });
    },

    // on initial environment is set where reports are added.
    onPrepare: function() {
        jasmine.getEnv().addReporter(reporter);
    },

    // Timeout can be adjusted according to your suitability by default it's 10 seconds.
    allScriptsTimeout: 500
};



Reports Screenshot for a Single Page 

The below screenshots are generated by a screenshot generator. When we run the script we can configure it with a screenshot reporter.

1) The initial top view generated by the ProtractorJS screen reporter.

Image title

2) Auto filling the field using the values assigned in using 'sendKeys'.Image title

3) The final report generated by the screenshot generator with specs which are failed and passed.

Image title


For More Info

For more info and codebase related stuff, please visit my GitHub repo. 

Feel free to raise a PR and contribute for the same, PR's are welcome!

Please comment for queries below, will be talking about cool stuff more as well.

Jasmine (JavaScript testing framework) Command (computing) IT Pass (software) GitHub Npm (software) Requests terminal

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Spring Boot, Quarkus, or Micronaut?
  • How To Handle Secrets in Docker
  • Fargate vs. Lambda: The Battle of the Future
  • The 5 Books You Absolutely Must Read as an Engineering Manager

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: