我有同样的问题:我正在开发一个脚本已由某人开发的项目。我发现现在很难整合cucmber。有人可以指导吗?
以下是steps.js和nightwatch.conf.js文件:问题:Nightwatch正在运行。但是,我没有看到黄瓜跑。没有'Given,When,Then'场景显示在cmd prmpt中。
nightwatch.conf.js:
module.exports = function(){
require('nightwatch-api')({
cucumberArgs: [
'--require',
'steps-definitions',
'--format',
'node_modules/cucumber-pretty',
'--require',
'cucumber.conf.js',
'Features/Main.feature'
]
});
}
module.exports = (function(settings) {
settings.selenium.server_path = require('selenium-server-standalone-jar').path;
settings.selenium.cli_args['webdriver.chrome.driver'] = require('chromedriver').path
return settings;
})(require('./nightwatch.json'));
Steps.js文件:
const { client } = require('nightwatch-api');
const { Given, When, Then } = require('cucumber');
Given(/^I open Google`s search page$/,function () {
return client
.url('http://google.com')
//.waitForElementVisible('body', 1000);
});
When('the title is "Google"', function (text) {
await client.assert.title(text);
});
Then('the Google search form exists', function () {
await client.assert.visible('input[name="q"]');
});
Nightwatch.json
{
"src_folders" : ["tests"],
"output_folder" : "reports",
"custom_commands_path" : "",
"custom_assertions_path" : "",
"page_objects_path" : "pages",
"globals_path" : "",
"selenium" : {
"start_process" : true,
"server_path" : "",
"log_path" : "",
"port" : 4444,
"cli_args" : {
"webdriver.chrome.driver" : "",
"webdriver.gecko.driver" : "",
"webdriver.edge.driver" : ""
}
},
"test_settings" : {
"default" : {
"launch_url" : "https://aem-staging-uk.stcdev.com/",
"selenium_port" : 4444,
"selenium_host" : "localhost",
"silent": true,
"screenshots" : {
"enabled" : true,
"path" : "./screenshots",
"on_failure": true,
"on_error": true
},
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled" : true,
"acceptSslCerts" : true,
"chromeOptions" : {
"args" : ["--no-sandbox", "--window-size=1920,1080", "--no-gpu"]
}
}
},
"staging":{
"launch_url" : "https://staging.stcdev.com/"
},
"qa6.3":{
"launch_url" : "https://aem-qa1-uk.stcdev.com/"
},
"staging6.3":{
"launch_url" : "https://aem-staging-uk.stcdev.com/"
}
}
}
你能解释一下你的问题吗?我也在使用与node.js相同的框架Nightwatch.js和cucumber-JS
你错过了守夜人黄瓜。如果您仍需要帮助,我会在稍后提供更多详细信息。