Joe*_*luh 7 angularjs protractor
我正在寻找一种ElementFinder从测试中扩展量角器类的方法.有没有办法访问量角器的ElementFinder类/构造函数,所以我可以在测试中动态扩展它?
量角器暴露的所有全局变量的参考也非常有用.
我正在使用以下解决方法$('').constructor;将ElementFinder功能扩展到#1102.
/**
* Current workaround until https://github.com/angular/protractor/issues/1102
* @type {Function}
*/
var ElementFinder = $('').constructor;
// Examples:
/**
* Schedules a command to compute the width of this element's
* bounding box, in pixels.
* @return {!webdriver.promise.Promise.<number>} A promise that will
* be resolved with the element's width as a {@code {number}}.
*/
ElementFinder.prototype.getWidth = function() {
return this.getSize().then(function(size) {
return size.width;
});
};
/**
* Schedules a command to compute the height of this element's
* bounding box, in pixels.
* @return {!webdriver.promise.Promise.<number>} A promise that will
* be resolved with the element's height as a {@code {number}}.
*/
ElementFinder.prototype.getHeight = function() {
return this.getSize().then(function(size) {
return size.height;
});
};
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1580 次 |
| 最近记录: |