Automation 错误:(0,_.And)不是函数

Automation 错误:(0,_.And)不是函数,automation,cucumber,keyword,gherkin,feature-file,Automation,Cucumber,Keyword,Gherkin,Feature File,我试图在Cucumber中使用'And'关键字,但出现了此错误。有人能告诉我这背后的原因吗 在步骤定义中: import { When,Then,And } from 'cucumber'; Given(/^User goes to login page$/, () => { loginPage.goToLogin(); }); And(/^Enters wrong credentials$/, () => { loginPage.enterData(); }); 在要

我试图在
Cucumber
中使用'And'关键字,但出现了此错误。有人能告诉我这背后的原因吗

在步骤定义中:

import { When,Then,And } from 'cucumber';

Given(/^User goes to login page$/, () => {
  loginPage.goToLogin();
});

And(/^Enters wrong credentials$/, () => {
  loginPage.enterData();
});
在要素文件中,它用作:

Given User goes to login page
And Enters wrong credentials
运行测试用例时,出现以下错误:

ERROR: (0 , _cucumber.And) is not a function

您不必在步骤定义中使用
。您可以在步骤定义中使用
给定的
然后
甚至
时使用
。关键词
但是
主要用于特征文件中,通过书写使其阅读更流畅

比如说--

..#。特征

。。 #.StepDefinition.js

import { Given, Then, When } from "cucumber";

let chai = require('chai');
global.expect = chai.expect;



  Given(/^I go to the google site$/, () => {
    browser.url("http://www.google.com");
  });

  When(/^I go to the google site again$/, () => {
    browser.url("http://www.google.com");
  });

  Then(/^I expect the title of the page "([^"]*)"$/, (title) => {
    expect(browser.getTitle()).to.be.eql(title);
  });

这会有用的。

谢谢。这很有帮助。我想在步骤定义中使用和。我该怎么做呢。
import { Given, Then, When } from "cucumber";

let chai = require('chai');
global.expect = chai.expect;



  Given(/^I go to the google site$/, () => {
    browser.url("http://www.google.com");
  });

  When(/^I go to the google site again$/, () => {
    browser.url("http://www.google.com");
  });

  Then(/^I expect the title of the page "([^"]*)"$/, (title) => {
    expect(browser.getTitle()).to.be.eql(title);
  });