@progress/kendo-e2e
Version:
Kendo UI end-to-end test utilities.
100 lines • 4.62 kB
JavaScript
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ListView = void 0;
const ui_component_1 = require("./ui-component");
const const_1 = require("./const");
const selenium_1 = require("../selenium");
class ListView extends ui_component_1.UIComponent {
constructor(browser, locator = ListView.SELECTOR, parentElement) {
super(browser, locator, parentElement);
this.parentElement = parentElement;
}
getContent() {
return __awaiter(this, void 0, void 0, function* () {
return yield this.findChild('.k-listview-content');
});
}
items() {
return __awaiter(this, void 0, void 0, function* () {
return yield this.findChildren('.k-listview-content .k-listview-item');
});
}
getItem(index) {
return __awaiter(this, void 0, void 0, function* () {
return (yield this.items())[index];
});
}
isItemSelected(index) {
return __awaiter(this, void 0, void 0, function* () {
return (yield (yield this.getItem(index)).getAttribute('class')).includes('k-selected');
});
}
isItemFocused(index) {
return __awaiter(this, void 0, void 0, function* () {
return (yield (yield this.getItem(index)).getAttribute('class')).includes('k-focus');
});
}
getEditItem(index) {
return __awaiter(this, void 0, void 0, function* () {
const editItems = yield this.findChildren('.k-listview-content .k-edit-item');
return editItems[index];
});
}
fieldLabel(itemIndex, fieldIndex) {
return __awaiter(this, void 0, void 0, function* () {
const item = yield this.getItem(itemIndex);
return yield ((yield this.browser.findChildren(item, 'dt'))[fieldIndex]).getText();
});
}
fieldText(itemIndex, fieldIndex) {
return __awaiter(this, void 0, void 0, function* () {
const item = yield this.getItem(itemIndex);
return yield ((yield this.browser.findChildren(item, 'dd'))[fieldIndex]).getText();
});
}
openItemForEdit(itemIndex) {
return __awaiter(this, void 0, void 0, function* () {
yield (yield this.browser.findChild(yield this.getItem(itemIndex), '.k-svg-i-pencil')).click();
});
}
deleteItem(itemIndex) {
return __awaiter(this, void 0, void 0, function* () {
const button = yield this.browser.findChild(yield this.getItem(itemIndex), '.k-delete-button');
yield button.click();
yield this.browser.wait(selenium_1.EC.notVisible(button), { timeout: 5000, message: 'Failed to delete item.' });
yield this.browser.sleep(200);
});
}
updateItem(itemIndex_1) {
return __awaiter(this, arguments, void 0, function* (itemIndex, { waitForUpdate = true } = {}) {
const check = yield this.browser.findChild(yield this.getEditItem(itemIndex), '.k-svg-i-check');
yield check.click();
if (waitForUpdate) {
yield this.browser.wait(selenium_1.EC.notVisible(check), { timeout: 5000, message: 'Failed to update item.' });
yield this.browser.sleep(200);
}
});
}
cancelItemEdit(itemIndex_1) {
return __awaiter(this, arguments, void 0, function* (itemIndex, { waitForUpdate = true } = {}) {
const cancel = yield this.browser.findChild(yield this.getEditItem(itemIndex), '.k-cancel-button');
yield cancel.click();
if (waitForUpdate) {
yield this.browser.wait(selenium_1.EC.notVisible(cancel), { timeout: 5000, message: 'Failed to cancel edit item.' });
yield this.browser.sleep(200);
}
});
}
}
exports.ListView = ListView;
ListView.SELECTOR = const_1.SELECTORS.LISTBOX;
//# sourceMappingURL=listview.js.map