我正在使用下面的代码片段来打印元素ID中的内容,但是内容没有按预期打印。在这篇文章中,我被要求使用等待/完成。我对这个框架非常陌生,想知道如何使用它。
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);
});
}
}
答案 0 :(得分:0)
异步/等待的示例
#!/usr/bin/perl
use warnings;
use strict;
use Cpanel::JSON::XS;
use Cpanel::JSON::XS::Type;
my $type = json_type_arrayof({
dt => JSON_TYPE_STRING,
nt => JSON_TYPE_INT,
flt_sm => JSON_TYPE_FLOAT,
str => JSON_TYPE_STRING,
str_flt => JSON_TYPE_FLOAT,
flt_lg => JSON_TYPE_FLOAT,
});
my $data = [{
dt => "2018-10-05 09:42:43.483",
nt => 1234,
flt_sm => ".0123",
str => "Hello there",
str_flt => "0.0123",
flt_lg => "10.1234",
}];
my $jsonizer = Cpanel::JSON::XS->new->canonical->pretty;
print $jsonizer->encode($data, $type);
或done()函数
Given('I open Google`s search page', async () => {
await client.url('http://google.com');
});