UNPKG

systelab-components-test

Version:

Widgets to be use in the E2E Tests based in Protractor

103 lines (102 loc) 4.33 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var widget_1 = require("./widget"); var protractor_1 = require("protractor"); var MultipleComboBox = /** @class */ (function (_super) { tslib_1.__extends(MultipleComboBox, _super); function MultipleComboBox() { return _super !== null && _super.apply(this, arguments) || this; } MultipleComboBox.prototype.click = function () { 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.click()]; case 1: _a.sent(); return [2 /*return*/]; } }); }); }; MultipleComboBox.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.css('.ag-cell-value')); 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).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]; } }); }); }; MultipleComboBox.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.css('.ag-selection-checkbox')) .get(i).click()]; case 1: _a.sent(); return [2 /*return*/]; } }); }); }; MultipleComboBox.prototype.selectOptionByText = function (text) { return tslib_1.__awaiter(this, void 0, void 0, function () { var index, rows, numberOfItems, i, cellText; return tslib_1.__generator(this, function (_a) { switch (_a.label) { case 0: index = -1; rows = this.elem.all(protractor_1.by.css('.ag-cell-value')); 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).getText()]; case 3: cellText = _a.sent(); if (cellText === text) { index = i; } _a.label = 4; case 4: i++; return [3 /*break*/, 2]; case 5: if (!(index != -1)) return [3 /*break*/, 7]; return [4 /*yield*/, this.selectOptionByNumber(index)]; case 6: _a.sent(); _a.label = 7; case 7: return [2 /*return*/]; } }); }); }; return MultipleComboBox; }(widget_1.Widget)); exports.MultipleComboBox = MultipleComboBox;