-1

enter code hereI am able to run the feature file if no parameters in the scenario. With parameter I been getting this ? Given User has successfully navigated to the Manufacturing "DEV" Application Undefined. Implement with the following snippet:

     Given('User has successfully navigated to the Manufacturing {string} Application', function (string) {
       // Write code here that turns the phrase above into concrete actions
       return 'pending';
     });

feature

LoginSteps

LoginPage

package.json

feature:

Feature: Protractor Test
  
  @TEST
  Scenario Outline: Login Test
    Given User has successfully navigated to the Manufacturing "<ENV>" Application

    Examples:
    | ENV   |
    | DEV   |

LoginSteps.ts

import { browser, protractor } from "protractor";
import {LoginPage} from "../pages/LoginPage";
const { When, Then , Given} = require("cucumber");
const loginpage: LoginPage = new LoginPage();

Given('User has successfully navigated to the Manufacturing (.*?) Application.', async (env) => {
  await loginpage.OpenBrowser(env)

});



Loginpage.ts
import {browser, by, element, $, ElementFinder} from 'protractor';

export class LoginPage {

     OpenBrowser = async (env) => {
        switch (env) {
            case("DEV"):
                await browser.sleep(5000);
                await browser.get("https://angularjs.org/");

        }
    }
}

   

    enter code here
Marit
  • 2,399
  • 18
  • 27
monika
  • 13
  • 2

1 Answers1

0

Due to the regular expression the step in the step definition needs to be:

Given('User has successfully navigated to the Manufacturing "(.*?)" Application.', async (env) => { 
    await loginpage.OpenBrowser(env)
});