量角器黄瓜配置文件无法识别黄瓜步骤定义文件



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

我尝试了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)

步骤定义文件

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)
});
};

在我的研究中,我没有错过设置中的任何内容,并且所有内容都在我的系统中设置并下载了所需的依赖项。

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

其次,确保所有功能步骤都应在步骤定义文件中实现,并且每个步骤的文本应与功能中提到的相同。

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

最新更新