對於protracor有點新手,但我試圖實現的基本上是一個檢查(從另一個函數)執行一個操作,然後執行相同的檢查(從早先的相同函數)。兩個函數的比較結果
我曾嘗試以下,但unforunately得到Failed: first is not defined
checkCanvasWidth: {
value: function() {
return element(by.css("div[class='canvasWrapper'] > canvas")).getAttribute("width").then(function(width) {
return width;
});
}
},
zoomIn: {
value: function() {
this.checkCanvasWidth().then(function (width) {
var first = width;
console.log("before:" + width);
});
//performs a click
this.clickZoomIn();
this.checkCanvasWidth().then(function (width) {
var second = width;
console.log("after:" + width);
});
expect(first).toBeGreaterThan(second);
}
}
任何幫助將大規模感激!
謝謝Shilly,我確實需要承諾版本!這是我正在努力,但沒有意識到 –