0

I am trying to set up an automation frameowrk for testing my angular web app. For this we are using protractor with jasmine and cucumber. I am running into multiple issues : Below is the package.json and I made sure to include the dependencies for cucumber , selenium web driver manager and I did install protractor-cucumber-framework using below command:

 npm install --save-dev protractor-cucumber-framework

package.json file:

{
  "name": "taweb",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve --proxy-config proxy.conf.json",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "test-unit": "ng test"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^7.0.2",
    "@angular/cdk": "^7.0.3",
    "@angular/common": "~7.0.0",
    "@angular/compiler": "~7.0.0",
    "@angular/core": "~7.0.0",
    "@angular/forms": "~7.0.0",
    "@angular/http": "~7.0.0",
    "@angular/platform-browser": "~7.0.0",
    "@angular/platform-browser-dynamic": "~7.0.0",
    "@angular/router": "~7.0.0",
    "core-js": "^2.5.4",
    "font-awesome": "^4.7.0",
    "ngx-logger": "^3.0.5",
    "hammerjs": "^2.0.8",
    "primeicons": "^1.0.0",
    "primeng": "^6.1.6",
    "rxjs": "~6.3.3",
    "selenium-webdriver": "^4.0.0-alpha.1",
    "zone.js": "~0.8.26",
    "webpack": "~4.16.4",
    "webpack-config": "~7.5.0",
    "har-validator": "~5.1.3"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.10.0",
    "@angular/cli": "~7.0.4",
    "@angular/compiler-cli": "~7.0.0",
    "@angular/language-service": "~7.0.0",
    "@types/jasmine": "~2.8.8",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "chai": "^4.1.2",
    "chai-as-promised": "^7.1.1",
    "codelyzer": "~4.5.0",
    "cucumber": "^4.2.1",
    "cucumber-html-reporter": "^4.0.3",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~3.0.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-firefox-launcher": "^1.1.0",
    "karma-ie-launcher": "^1.0.0",
    "karma-jasmine": "~1.1.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.4.0",
    "protractor-beautiful-reporter": "^1.2.3",
    "protractor-cucumber-framework": "^6.1.1",
    "ts-node": "~7.0.0",
    "tslint": "~5.11.0",
    "typescript": "~3.1.1"
  }
}

Also installed the below plugins from protractor:

-Cucumber Gherkin Full Support

-cucumber-gotostep

Issues faced: 1) When I create a feature file" test1.feature" and start adding scenario and right click then its not giving me an option to add step definition. Only one option related to Cucumber is showing which is "Go to Step definition". 2) I am not seeing the cucumber icon for the above feature file. Not sure what I am missing here Below is my config.ts:

import * as path from "path";
import { browser, Config } from "protractor";
import { Reporter } from "../support/reporter";
const jsonReports = process.cwd() + "/reports/json";

export const config: Config = {

    seleniumAddress: "http://127.0.0.1:4444/wd/hub",

    SELENIUM_PROMISE_MANAGER: false,

    baseUrl: "https://www.google.com",

    capabilities: {
        browserName: "chrome",
    },

    framework: "custom",
    frameworkPath: require.resolve("protractor-cucumber-framework"),

    specs: [
        //"../../features/*.feature",
        "src/Test/features/*.feature",
    ],

    onPrepare: () => {
        browser.ignoreSynchronization = true;
        browser.manage().window().maximize();
        Reporter.createDirectory(jsonReports);
    },

    cucumberOpts: {
        compiler: "ts:ts-node/register",
        format: "json:./reports/json/cucumber_report.json",
        //require: ["../../typeScript/stepdefinitions/*.js", "../../typeScript/support/*.js"],
        require: ["src/Test/steps/*.ts", "src/Test/support/*.ts"],
        strict: true,
        tags: "@CucumberScenario or @ProtractorScenario or @TypeScriptScenario or @OutlineScenario",
    },

    onComplete: () => {
        Reporter.createHTMLReport();
    },
};

3) When I am trying to run above feature file using node_modules.bin\cucumber-js "Test1.feature" it shows the below :

0 scenarios
0 steps
0m00.000s

4) Also I am unable to see the webdriver manager jar files in the below location: When I ran the commands :

node_modules\.bin\webdriver-manager update
node_modules\.bin\webdriver-manager start

It gives error as

events.js:167
      throw er; // Unhandled 'error' event
      ^

Error: connect ETIMEDOUT 172.217.7.208:443
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1113:14)
Emitted 'error' event at:
    at Request.onRequestError (..\..\node_modules\request\request.js:881:8)
    at ClientRequest.emit (events.js:187:15)
    at TLSSocket.socketErrorListener (_http_client.js:391:9)
    at TLSSocket.emit (events.js:182:13)
    at emitErrorNT (internal/streams/destroy.js:82:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
    at process._tickCallback (internal/process/next_tick.js:63:19)

How can I add the webdriver-manager related jar files as part of my npm package so that I can update and start it ?

Any help is much appreciated.Thanks!

user5252179
  • 133
  • 3
  • 20

1 Answers1

0

Why are you not running your config file with Protractor.

You have specified your framework,selenium address,specs file location and feature files location. You should run the config file with protractor.

https://github.com/igniteram/protractor-cucumber-typescript

To avoid webdriver-manager refer the below post.

https://stackoverflow.com/a/53358685/8903949

Bharath Kumar S
  • 1,410
  • 2
  • 10
  • 29
  • I ran my config file using "node_modules\protractor\bin\protractor src/Test/config/config.ts" command but it gave me the below error: node Error: [16:39:17] E/configParser - Error code: 105 [16:39:17] E/configParser - Error message: failed loading configuration file src/Test/config/config.ts – user5252179 Dec 06 '18 at 21:47
  • Sorry I wasnt able to format code in the above comments. Ctrl K didnt work – user5252179 Dec 06 '18 at 21:51
  • Issue fixed? Are you able to run the test? – Bharath Kumar S Dec 07 '18 at 07:45
  • No still not able to run as mentioned above. Getting Error: [16:39:17] E/configParser - Error code: 105 [16:39:17] E/configParser - Error message: failed loading configuration file src/Test/config/config.ts – user5252179 Dec 10 '18 at 15:09