npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

protractor-screenshot-utils

v1.0.6

Published

A simple utility to capture fullpage screenshot, screenshot of any element and crop the screenshot by any screen coordinates from your e2e protractor tests out-of-box

Downloads

2,571

Readme

Build Status Code Coverage

protractor-screenshot-utils

A simple utility to capture fullpage screenshot, screenshot of any element and crop the screenshot by any screen coordinates from your e2e protractor tests out-of-box.

Features

  1. This module can take fullpage screenshots of any webpage.
  2. It can take screenshot of any given WebElement.
  3. It also has the ability to crop the screenshot with given co-ordinates of screen.
  4. Automatically save the captured screenshot in given path.
  5. Overrides default browser.getScreenshot() method to capture full page screenshots.

Preview

How to install

npm install protractor-screenshot-utils

Usage

Add add the below code to protractor config file:

Example:

protractor.config.js

var screenShotUtils = require("protractor-screenshot-utils").ProtractorScreenShotUtils;
exports.config = {
    framework: 'jasmine2',
      onPrepare: function() {
          global.screenShotUtils = new screenShotUtils({
            browserInstance : browser
          });
      }
};

That's it. Now you can take fullpage screenshots from your tests by just using any of the below code.

Taking fullPage screenshot

screenShotUtils.takeScreenshot().then(function(base64string){
    //logic to save the image to file.
})

or you can also directly save the image as file using

screenShotUtils.takeScreenshot({
   saveTo: "fullpageScreenshot.png"
})

Above code will automatically saves the screenshot as fullpageScreenshot.png file.

Taking screenshot of any element

screenShotUtils.takeScreenshot({
   element : element(by.id("header")), //you can pass any protractor element
   saveTo: "headerElement.png"
})

Taking screenshot by screen co-ordinates

screenShotUtils.takeScreenshot({
   dimensions : {
       x:20, //starting x point
       y:40, //startng y point
       width : 200,
       height: 200
   },
   saveTo: "croppedImage.png"
})

You can also crop the screenshot of an element by using

screenShotUtils.takeScreenshot({
   element : element(by.id("main-container")),
   dimensions : {
       x:20, //starting x point
       y:40, //startng y point
       width : 200,
       height: 200
   },
   saveTo: "croppedElementImage.png"
})

Additional Funtionalities:

Override default browser.takeScreenshot()

If your using any html-screenshot reporter in your test,then those reporters will call browser.takeScreenshot() to capture the screenshot of webpage in case of any failures in test. If you want to override default behaviour of browser.takeScreenshot() to caputer full page screenshot, you can use,

global.screenShotUtils = new screenShotUtils({
    browserInstance : browser,
    setAsDefaultScreenshotMethod : true //this will override default browser.takeScreenshot() method to take full page image.
});

And you can now take fullpage screen shot, element screenshot using browser.takeScreenshot() with all options given in above examples.