Кто-нибудь знает, почему этот шаг может отображаться как «undefined», когда я пытаюсь его запустить. ниже вы увидите пример, в котором я пытаюсь поэкспериментировать со схемой сценария с огурцом, и в моем разделе «Примеры:» есть одна запись. Также включены объекты страницы и шаг def. По какой-то причине, когда я пытаюсь запустить его, я получаю такую ошибку:
1) Scenario: Verify user can search # ..\features\automation\regression\samplezz.feature:13
√ Before # ..\support\world.js:21
√ Given I navigate to the ea site # ..\step_definitions\ea_page_steps.js:4
√ Then I click on the search icon # ..\step_definitions\ea_page_steps.js:8
? When I search for the word angular
Undefined. Implement with the following snippet:
When('I search for the word angular', function (callback) {
// Write code here that turns the phrase above into concrete actions
callback(null, 'pending');
});
Вот файл функции
Feature: sampleZZ
The purpose of this feature file is to navigate to the eaAutomationa site
Scenario Outline: Verify user can search
Given I navigate to the ea site
Then I click on the search icon
When I search for the word <word>
Examples:
|word|
|angular|
вот шаг def:
let {Given, Then, When} = require('cucumber');
Given(/^I navigate to the ea site$/, function(){
return browser.get(this.url.ud); });
Then(/^I click on the search icon$/, function(){
return this.pages.udPage.click_Search();
});
When(/^I search for the word "([^"]*)" $/, function(word){
return this.pages.udPage.enter_SearchText(word) });
Вот объекты страницы
class UDPage extends require('../base_page.js') { constructor() {
super();
this.eaautomation = by.css('#new_searchicon > i');
this.eaLogo = by.css('//#header_logo'); }; click_Search() {
return element(this.eaautomation).click(); }
enter_SearchText(text){
return element(this.eaautomation).sendKeys(text); }
} module.exports = UDPage;
Примечание. У меня есть универсальный конструктор во фреймворке, поэтому мне не нужно импортировать какие-либо страницы, когда я пишу свой тест. Может ли кто-нибудь помочь мне понять, что не так с шагом 3, который продолжает показывать undefined?
используя следующие
"зависимости": {"чай": "4.1.2", "чай как обещанный": "7.1.1", "шакрам": "1.5.0", "огурец": "4.0.0", " огурец-html-reporter ":" 3.0.4 "," fs ":" 0.0.2 "," path ":" 0.12.7 "," транспортир ":" 5.3.0 "," транспортир-огурец-каркас " : "4.2.0"}
EDITED - для добавления config.js
let path = require('path'),
environment = require('./environment');
exports.config = Object.assign({}, environment, {
seleniumAddress: 'http://localhost:4444/wd/hub', // 'http://localhost:4444/wd/hub' to run locally
capabilities: {
"browserName": "chrome",
"shardTestFiles": true,
"maxInstances": 1,
"ignoreProtectedModeSettings": true
},
specs:[
'../features/automation/regression/sample2.feature',
],
params: {
environment: 'qa1', // dit, qa4, or qa1
platform: 'browser', // browser or mobile
path: {
page_objects: path.resolve(__dirname + '/../page_objects'), // Default directory for the page objects
page_factory: path.resolve(__dirname + '/../page_objects/page_factory.js'), // Default page factory location
projectRoot: path.resolve(__dirname + '/../') // Default root for the automation
}
}
});