Javascript 元素。getText()。然后(函数)未被执行
我正在使用量角器和黄瓜。我想打印从getText返回的文本。我正在使用.then函数获取这样的文本,但由于某种原因,Javascript 元素。getText()。然后(函数)未被执行,javascript,protractor,cucumber,bdd,angular-promise,Javascript,Protractor,Cucumber,Bdd,Angular Promise,我正在使用量角器和黄瓜。我想打印从getText返回的文本。我正在使用.then函数获取这样的文本,但由于某种原因,console.logcode没有被执行 为什么会这样 progrator.conf.js文件是: 量角器文件是: exports.config = { seleniumAddress: 'http://localhost:4444/wd/hub', // This is targetting your local running instance of the selenium
console.log
code没有被执行
为什么会这样
progrator.conf.js文件是:
量角器文件是:
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub', // This is targetting your local running instance of the selenium webdriver
specs: [
'../Features/UI_Tests.feature'
],
capabilities: {
browserName: 'chrome' // You can use any browser you want. On a CI environment you're going to want to use PhantomJS
},
framework: 'custom', //We need this line to use the cucumber framework
frameworkPath: require.resolve('protractor-cucumber-framework'), // Here it is
cucumberOpts: {
//format: 'pretty',
require: '../Features/step_definitions/my_steps.js', // This is where we'll be writing our actual tests
//tags: ['@login','@app'],
strict: true,
plugin:"json"
},
resultJsonOutputFile:'./testResults.json', //output file path to store the final results in .json format
params: {
env: {
hostname: 'http://0.0.0.0:8000' // Whatever the address of your app is
}
}
};
提前感谢。可能是您记录为空的文本值 您能否尝试在文本前面添加一些测试
name.getText().then((text)=>{
console.log('Text value is' + text);
});
只是为了检查console.log是否执行。可能承诺被拒绝?我不知道,我如何检查它是否被拒绝?使用。请显示我们的dragotor conf.js您可以看到我的dragotor.conf.js文件我已经做了,但什么也没有发生。我还调试了代码,并且没有执行console.log()。谢谢你的回答,巴拉斯
name.getText().then((text)=>{
console.log('Text value is' + text);
});