Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/390.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 元素。getText()。然后(函数)未被执行_Javascript_Protractor_Cucumber_Bdd_Angular Promise - Fatal编程技术网

Javascript 元素。getText()。然后(函数)未被执行

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

我正在使用量角器和黄瓜。我想打印从getText返回的文本。我正在使用.then函数获取这样的文本,但由于某种原因,
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);
 });