Javascript 无法在量角器中指定承诺之外的变量

Javascript 无法在量角器中指定承诺之外的变量,javascript,protractor,Javascript,Protractor,我无法得到承诺之外的价值。i、 e代码段中的最后一个计数变量 我正在使用量角器+javascript+jasmine你试过这个吗 self.getDocumentCount().then(function (text) { var stringArray = text.split("("); count = stringArray[0].trim(); }).then(function () { self.logger.info("Doc

我无法得到承诺之外的价值。i、 e代码段中的最后一个计数变量

我正在使用量角器+javascript+jasmine

你试过这个吗

 self.getDocumentCount().then(function (text) {
        var stringArray = text.split("(");
        count = stringArray[0].trim();
    }).then(function () {
        self.logger.info("Document text : " + count, self);
    });
    self.logger.info("Checking the count again : " + count, self);

getDocumentCount()?我的意思是console.log(text)给了你什么输出?console.log(text)在promise中给了我文档的计数(即是必需的结果)。如果我尝试在承诺之外获取相同的值,我将得到未定义的结果,那么您不能将承诺返回的结果本身存储在那里吗?不,这就是问题所在。您能否提供有关tempObjecttempObject的更多信息?TempObject是示例代码中的数组变量。但如果愿意,也可以使用正态变量。
var tempObject = {}

it('should get count', function() {
      getDocumentCount(strDoc);
});

it('should display count', function() {
      console.log(tempObject.Count);
});

function = getDocumentCount(text) {
    var stringArray = text.split("(");
    tempObject.Count = stringArray[0].trim();
})