Coder Social home page Coder Social logo

harshalslimaye / protractor-cucumber-typescript Goto Github PK

View Code? Open in Web Editor NEW
1.0 0.0 0.0 36 KB

e2e boilerplate which consists of Protractor, CucumberJS and TypeScript

Home Page: https://harshal.co

License: MIT License

TypeScript 81.77% Gherkin 18.23%
protractor cucumber typescript angular protractor-cucumber gherkin testing end-to-end-testing chai bdd-framework

protractor-cucumber-typescript's Introduction

Protractor

Protractor Cucumber TypeScript

This project is a barebones implementation of Protractor with Cucumber framework using TypeScript.

Prerequisistes

  1. NodeJS
  2. Web Browser - Chrome/Firefox
  3. Code Editor - Visual Studio Code/Atom/Sublime

Setup

  1. Open your terminal / command prompt
  2. Clone the repository to your computer
git clone https://github.com/harshal-limaye/protractor-cucumber-typescript.git
  1. Navigate to the repository and run following command.
npm install

This will install all the dependencies mentioned in the package.json file and copy them inside node_modules folder.

Usage

Use the following command to download the necessary binaries.

npm run driver-update

Next, to start the Selenium server use the following command.

npm run driver-start

And finally run following command to start the test

npm test

Folders

  1. features - used to store .feature files.
Feature: Testing Calculator

    @Calculator
    Scenario Outline: Testing All Functions
        Given go to "https://juliemr.github.io/protractor-demo/"
        When first number is "<n1>"
        When second number is "<n2>"
        When operation to be performed is "<op>"
        When operation in progress
        Then output should be "<ot>"

    Examples:
    | n1 | n2 | op | ot |
    | 2  | 4  | +  | 6  |
    | 8  | 3  | -  | 5  |
    | 2  | 5  | *  | 10 |
    | 25 | 5  | /  | 5  |
    | 10 | 3  | %  | 1  |
  1. stepdefinitions - contains step definition files in typescript format.
import { Given } from 'cucumber';
import { browser } from 'protractor';

Given('go to {string}', async (url) => {
    await browser.get(url);
})
  1. pages - used to store page objects
import { by, element, ElementFinder } from "protractor";

export class CalcPage {
  firstNumber: ElementFinder;
  secondNumber: ElementFinder;
  operator: ElementFinder;
  button: ElementFinder;
  results: any;

  constructor() {
    this.firstNumber = this.getElByModel("first");
    this.secondNumber = this.getElByModel("second");
    this.operator = this.getElByModel("operator");
    this.button = element(by.id("gobutton"));
    this.results = element(by.repeater("result in memory")).element(by.css("td:nth-child(3)"))
  }

  getElByModel(modelName) {
    return element(by.model(modelName));
  }
}

Reports

This project uses Cucumber HTML Reporter package to generate reports. It generates a two files report.json and report.html at the root of this repository each time npm test command is fired.

You can change the report file names and there locations by simply updating configuration object passed to reporter.generate method inside config.ts file located inside config folder.

Notes

Change browser

Out-of-the-box this project uses chrome as to run the tests, however you could easily change it to Firefox by updating capabilities inside config.ts file.

capabilities: {
    browserName: "chrome"
}

protractor-cucumber-typescript's People

Contributors

harshalslimaye avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.