<分区>
我有一个尺寸和位置未知的 Canvas 。我想根据 Protractor 中 Canvas 的尺寸和位置模拟点击特定坐标。
以下工作,但相当乏味:
var canvas = element(by.id("canvas"));
canvas.getCssValue("left").then(function (left) {
canvas.getCssValue("top").then(function (top) {
canvas.getCssValue("width").then(function(oldWidth) {
canvas.getCssValue("height").then(function (oldHeight) {
// some code that uses left, top, oldWidth and oldHeight together
})
})
})
}
)
})
})
是否有更优雅的方式同时使用所有这些 promise ?我真的很想做如下事情:
var width = canvas.getCssValue("width");
var height = canvas.getCssValue("height");
var left = canvas.getCssValue("left");
var top = canvas.getCssValue("top");
//code that uses these variables.
当然,如果违反 promise 的性质。感谢您的帮助。