在量角器黄瓜框架中使用 await/done
Using await/done in Protractor Cucumber Framework
我正在使用下面的代码片段打印元素 id.However 中的内容,但未按预期打印内容。在这个post中,我被要求使用await/done。我对这个框架很陌生,想知道如何使用它。
Empty response in Protractor console.log
var {defineSupportCode} = require('cucumber');
var chai = require('chai');
var chaiAsPromised = require('chai-as-promised');
chai.use(chaiAsPromised);
var expect = chai.expect;
defineSupportCode(function ({And, But, Given, Then, When}) {
Given(/^I launch Chrome browser$/, function () {
var elm = element(by.id('the-basics'));
elm.getText().then(function(txt) {
console.log("txt: " + txt);
});
}
}
async/await的例子
Given('I open Google`s search page', async () => {
await client.url('http://google.com');
});
或 done() 函数
Given(/I click something/, (done) => {
// do stuff
done();
}
我正在使用下面的代码片段打印元素 id.However 中的内容,但未按预期打印内容。在这个post中,我被要求使用await/done。我对这个框架很陌生,想知道如何使用它。
Empty response in Protractor console.log
var {defineSupportCode} = require('cucumber');
var chai = require('chai');
var chaiAsPromised = require('chai-as-promised');
chai.use(chaiAsPromised);
var expect = chai.expect;
defineSupportCode(function ({And, But, Given, Then, When}) {
Given(/^I launch Chrome browser$/, function () {
var elm = element(by.id('the-basics'));
elm.getText().then(function(txt) {
console.log("txt: " + txt);
});
}
}
async/await的例子
Given('I open Google`s search page', async () => {
await client.url('http://google.com');
});
或 done() 函数
Given(/I click something/, (done) => {
// do stuff
done();
}