我正在与量角器和cucumber
合作。我想打印从getText返回的文本。我正在使用.then函数获取此类文本,但是由于某些原因,console.log
代码未执行。
为什么会这样?
checkDropdown: function (value, dropdown) {
let name = element(by.id(dropdown));
name.getText().then(function(text){
console.log(text);
});
expect(name.getText()).to.eventually.equal(value);
},
protractor.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
}
}
};
谢谢。
答案 0 :(得分:0)
可能是您记录的文本值为空白。
您可以尝试在文本
前面添加一些测试吗 name.getText().then((text)=>{
console.log('Text value is' + text);
});
只需检查console.log是否已执行。