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-sync

v6.0.2

Published

Protractor 5.x wrapper adding synchronous, polled selectors and expectations

Downloads

55

Readme

What is this?

Protractor-sync builds on Protractor and provides:

  • Synchronous-style test writing (using fibers, behind the scenes) allowing all commands to execute immediately.
  • Polling mechanisms for testing asynchronous apps (polledExpect, elementFinderSync.waitUntil & .waitUntilRemoved, waitFor)
  • JQuery methods such as hasClass, closest, and is
  • Automatic stale element re-selection (if a stale element is encountered, try to re-select it based on its original selector)
  • Automatic blocked click retrying (if another element would receive the click, keep retrying until timeout expires)
  • Chaining (e.g. myElement.clear().sendKeys('text'))
  • Allows 'try/catch' syntax for straightforward error handling

Installation

Pre-reqs:

  • Protractor 5.3 or higher (or something like grunt-protractor-runner, which includes it)
  • asyncblock (npm install asyncblock)
  • Jasmine (Comes with Protractor. Other frameworks can be used, but some features only work with Jasmine)

Install: npm install protractor-sync

Example

import * as ab from 'asyncblock';
import { browserSync, configure, elementSync, polledExpect} from '../../app/index';

configure({ implicitWaitMs: 500 });

function createTest(fn: Function, errorMsg?: string) {
  return (done: Function) => {
    ab(() => {
      fn();
    }, (err: any) => {
      if (errorMsg) {
        expect(err.message).toEqual(errorMsg);
      } else {
        expect(err && err.stack || err || undefined).toBeUndefined();
      }
      done();
    });
  };
}

describe('Google Translate', () => {
  const googleTranslateUrl = 'https://translate.google.com/';

  it('does not show the clear button when no text exists in the source field', createTest(() => {
    browserSync.get(googleTranslateUrl);

    const rootElement = elementSync.findVisible('#gt-src-c');
    polledExpect(() => rootElement.findElement('.clear-button').isDisplayed()).toEqual(false);
  }));

  it('does show the clear button after entering text in the source field', createTest(() => {
    browserSync.get(googleTranslateUrl);

    const rootElement = elementSync.findVisible('#gt-src-c');
    rootElement.findVisible('textarea#source').clear().sendKeys('12345');
    polledExpect(() => rootElement.findElement('.clear-button').isDisplayed()).toEqual(true);
  }));
});

See test/spec/protractor-sync_test.ts for more examples.

How to contribute

Thanks you for your interest in Protractor-sync. In lieu of a formal style guide, take care to maintain the existing coding style. Please add tests for any new or changed functionality.

API

See API.md

Tips

  • Do not set an implicit wait in Protractor/selenium. Set an implicit wait time using protractorSync.configure instead.
  • Turn off Protractor synchronization (browserSync.getBrowser().waitForAngularEnabled(false);) for faster tests. You can also enable/disable it during portions of tests.
  • Always use findVisible, except for special situations where you want to select a hidden element.
  • If you must manually pass a waitTimeMS, set it as a multiple of the implicitWaitTimeMs so it will scale on slower machines.

Build tasks

  • npm start - Builds the code and watches for changes
  • npm test - Builds the code, runs the linter, updates Webdriver if needed, and runs the test suite
  • npm publish - Publish a new version to NPM

This project will automatically build, lint and test when pushing code to a remote repository.