Skip to content

Latest commit

 

History

History
64 lines (41 loc) · 3.56 KB

README.md

File metadata and controls

64 lines (41 loc) · 3.56 KB

protractor-tools npm version MIT license

A typescript rewrite of sg-protractor-tools utility library

Build Status dependencies Status devDependencies Status Greenkeeper badge PRs Welcome Codacy Badge

This library provides a reusable and generic set of helper functions for the Protractor test framework. It includes functions that simplify things like browser resizing, scrolling and memory usage tracking as part of a test suite. The project bundles an example application that showcases the functionality.

While using Protractor for testing our Angular-based applications, we have found that we can simplify many of the common tasks done as part of part of our test suite. The Protractor API is fairly low-level in some cases, and we have seen that we can cut down the amount of code for some common tasks by externalizing functionality into a reusable library.

Installing / Getting started

npm install -D protractor-tools

Install the library as a development dependency using the node package manager of your choice.

Usage

Import the required util classes in your *.e2e-spec.ts files.

import { ResizeUtil } from 'protractor-tools';

describe('Resizing demo App', () => {

      const resizeUtil = new ResizeUtil();

      it('should resize the browser window a little', () => {
        // ...
        resizeUtil.setWindowSize(1303, 876);
        // ...
      });
});

Features

The following utility classes are currently available

  • ConsoleUtil (retrieve console logs and convenience methods to ensure your app didn't produce console errors)
  • DomUtil (wait for dom elements to become visible or invisible)
  • MemoryUtil (execute an action multiple times and track the memory footprint of the app)
  • MouseUtil (drag and drop functionality)
  • ResizeUtil (get and set the browser window and viewport size)
  • ScrollUtil (scroll to a element, scroll to a coordinate/position or scroll by a number of pixels)

You may refer to the source code of the util classes for usage details or the forked library documentation for more information about the reason for the utility classes.

Links

Licensing

The code in this project is licensed under MIT license.