量角器黄瓜配置文件无法识别黄瓜stepdefinition文件

时间:2019-09-05 06:19:44

标签: protractor cucumber cucumberjs

无法执行步骤定义文件中的步骤

我尝试了google中存在的解决方案,但没有一个能回答我的问题。

我的配置文件

  //seleniumAddress: 'http://localhost:4444/wd/hub',
  directConnect: true,
  //specs: ['/Users/bharaniravisankar/Desktop/PRO/SPECS/TEST.JS'],
  framework: 'custom',
  // path relative to the current config file
  frameworkPath: require.resolve('protractor-cucumber-framework'),
  capabilities: {
    'browserName': 'chrome'
  },
  specs: [
    '/Users/bharaniravisankar/Desktop/PRO/Feature/test.feature'
  ],

  cucumberOpts: {
    require: '/Users/bharaniravisankar/Desktop/PRO/Feature/Step Definition/login.js',
    //tags: false,
    //format: 'pretty',
    profile: false,
    'no-source': true
  }

};

我的控制台日志

? Given User navigate to Home Page
       Undefined. Implement with the following snippet:

         Given('User navigate to Home Page', function () {
           // Write code here that turns the phrase above into concrete actions
           return 'pending';
         });

   ? When User enter email and other details
       Undefined. Implement with the following snippet:

         When('User enter email and other details', function () {
           // Write code here that turns the phrase above into concrete actions
           return 'pending';
         });

   ? And click on Submit button
       Undefined. Implement with the following snippet:

         When('click on Submit button', function () {
           // Write code here that turns the phrase above into concrete actions
           return 'pending';
         });

   ? Then Login is created sucessfully
       Undefined. Implement with the following snippet:

         Then('Login is created sucessfully', function () {
           // Write code here that turns the phrase above into concrete actions
           return 'pending';
         });

   ✔ After # CONG.js/node_modules/protractor-cucumber-framework/lib/resultsCapturer.js:26

1 scenario (1 undefined)
4 steps (4 undefined)

Stepdefinition文件

var { Given, When, Then } = require("cucumber");

module.exports = function () {

    this.Given(/^User navigate to Home Page$/, async function () {
     // this.When('User enter email and other details', function () {

        //launch AWS portal
        browser.get('https://portal.aws.amazon.com/billing/signup#/start');

        //Maximize the browser window
        browser.driver.manage().window().maximize();

        //Check the title of the Webpage
       expect(await browser.getTitle()).toEqual('AWS Console - Signup');


      });

      this.When(/^User enter email and other details$/, function () {
      //  this.When('User enter email and other details', function () {

        element(by.model('credentials.email')).sendKeys('bharaniravi36@gmail.com')
        element(by.model('credentials.password')).sendKeys('Feb%1992');
        element(by.model('credentials.rePassword')).sendKeys('Feb%1992');
        element(by.model('credentials.fullName')).sendKeys('bharaniravi85');

      });



      //this.When('click on Submit button', function () {

        this.When(/^click on Submit button$/, function () {

        element(by.xpath("(//input[@class='a-button-input'])[1]")).click();
      });

      this.Then(/^Login is created sucessfully$/, function () {

        expect(browser.getTitle()).toEqual('AWS Console - Signup');
        element(by.id('company')).sendKeys('POLI');

        //click on country drop down
        element(by.model("address.countryCode")).click();
        element(by.xpath("//option[@label='American Samoa']")).click();
              // add sleep to give a time for te options to reveal
              browser.sleep(3000)
      });
  };

在我的研究中,我没有错过任何设置,并且所有东西都已安装到系统中,并且下载了必需的依赖项。

1 个答案:

答案 0 :(得分:0)

首先尝试在功能文件夹之外创建步骤定义文件夹,以保持功能分离,步骤定义和文件夹名称应没有空格,例如“ stepdefinition”。

第二,确保所有功能步骤均应在步骤定义文件中实施,并且每个步骤的文本应与功能中提到的相同。

尝试使用它,如果适合您,请告诉我。