systelab-components-test
Version:
Widgets to be use in the E2E Tests based in Protractor
66 lines (65 loc) • 2.81 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var widget_1 = require("./widget");
var protractor_1 = require("protractor");
var ContextMenu = /** @class */ (function (_super) {
tslib_1.__extends(ContextMenu, _super);
function ContextMenu() {
return _super !== null && _super.apply(this, arguments) || this;
}
ContextMenu.prototype.getOptions = function () {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var content, rows, numberOfItems, i, text;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
content = [];
rows = this.elem.all(protractor_1.by.tagName('systelab-context-menu-item'));
return [4 /*yield*/, rows.count()];
case 1:
numberOfItems = _a.sent();
i = 0;
_a.label = 2;
case 2:
if (!(i < numberOfItems)) return [3 /*break*/, 5];
return [4 /*yield*/, rows.get(i).element(protractor_1.by.tagName('a')).getText()];
case 3:
text = _a.sent();
content.push(text);
_a.label = 4;
case 4:
i++;
return [3 /*break*/, 2];
case 5: return [2 /*return*/, content];
}
});
});
};
ContextMenu.prototype.selectOptionByNumber = function (i) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.elem.all(protractor_1.by.tagName('systelab-context-menu-item')).get(i).click()];
case 1:
_a.sent();
return [2 /*return*/];
}
});
});
};
ContextMenu.prototype.selectOptionByText = function (text) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.elem.element(protractor_1.by.cssContainingText('a', text)).click()];
case 1:
_a.sent();
return [2 /*return*/];
}
});
});
};
return ContextMenu;
}(widget_1.Widget));
exports.ContextMenu = ContextMenu;