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

v0.1.8

Published

Cucumber support for protractor

Downloads

469

Readme

protractor-cucumber

protractor-cucumber allows one to drive protractor tests using cucumber

Installation

Install npm package to dev dependencies

npm install protractor-cucumber --save-dev

Usage

Install Cucumber

npm install -g cucumber

Install protractor

npm install -g protractor

Update webdriver

webdriver-manager update

Start Selenium

webdriver-manager start

Create a feature file

Below demonstrates how to use protractor-cucumber

seleniumAddress is the address of a running selenium standalone server

protractor-cucumber returns a world object; which you can configure; with options described below.

Lets create a steps file in features/step_definitions/steps.js

var pc = require('protractor-cucumber');

var steps = function() {
  var seleniumAddress = 'http://localhost:4444/wd/hub';
  var options = { browser : 'chrome', timeout : 100000 };
  this.World = pc.world(seleniumAddress, options);

  this.After(function(scenario, callback) {
    this.quit(callback);
  });
};

module.exports = steps;

Now create a feature file, features/homepage.feature


Feature: Homepage 
  As a user
  I want to visit the homepage
  So that I can access the various features on offer

  Scenario: Visit Homepage
    Given I am on the homepage
    Then I should see a "navbar"
    And I should see a "login" link
    And I should see a "register" link

Now create some steps for the above feature, features/step_definitions/homepage/steps.js


var support = require('../support');

var steps = function() {

  this.Given(/^I am on the homepage$/, function(callback) {
    support.get(this, 'http://localhost:5000', function(result){
      setTimeout(callback, 1000);
    });
  });

  this.Then(/^I should see a "([^"]*)" link$/, function(link, callback) {
    support.findByBinding(this, link, function(result){
      result.getText().then (function(text){
        text.trim().toLowerCase().should.equal(link.trim().toLowerCase());             
        setTimeout(callback, 1000);
      });     
    });
  });

  this.Then(/^I should not see a "([^"]*)" link$/, function(link, callback) {
    support.isElementPresent(this, link, function(result){
      result.should.equal(false);
      setTimeout(callback, 1000);
    });
  });

  this.Then(/^I should see a "([^"]*)"$/, function(link, callback) {
    support.isElementPresentByClass(this, link, function(result){
      result.should.equal(true);
      setTimeout(callback, 1000);
    });
  });

};

module.exports = steps;

Add some support, features/step_definitions/support.js


var Support = function(){
};

Support.prototype.get = function(sut, url, callback){
  sut.browser.get(url).then(function(result) {
    callback(result)
  });
};

Support.prototype.findByBinding = function(sut, item, callback){
  sut.browser.findElement(sut.by.binding(item)).then(function(result) {
    callback(result);
  });
};

Support.prototype.isElementPresent = function(sut, find, callback){
  sut.browser.isElementPresent(sut.by.linkText(find)).then(function(result) {
     callback(result)
  });
};

Support.prototype.isElementPresentByClass = function(sut, find, callback){
  sut.browser.isElementPresent(sut.by.css('.'+find)).then(function(result) {
     callback(result)
  });
};

module.exports = new Support();

Now run cucumber:

cucumber.js

World

Below is a list of properties/methods exposed on the world object

browser

a wrapper around an instance of webdriver. Used for navigation and page-wide information.

protractor

the protractor lib

by

a collection of element locator strategies.

assert

our chosen assertion library, not required is using should

baseUrl

allows you to set a baseurl to use in your tests

properties

an object of anything you like to use in your tests

quit

quits the browser used in your tests

Options

browser

Specifies a browser; chrome, phantomjs, defaults to chrome

timeout

Specifies a timeout for setScriptTimeout, defaults to 100000

assert

Specifies an assert module; to use within your tests

baseUrl

Specifies a baseurl to be used within your tests

properties

Specifies a properties object; stick whatever you like in there

desiredCapabilities

Desired Capabilities passed to Selenium; Arbitrary object whose keys are capability names. Is merged with capabilites created for browser or can be used instead of browser.