d5-testing-library 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/d5-testing-library.cjs +387 -13
- package/dist/d5-testing-library.d.ts +109 -3
- package/dist/d5-testing-library.legacy-esm.js +386 -12
- package/dist/d5-testing-library.mjs +386 -12
- package/package.json +2 -2
|
@@ -114,10 +114,9 @@ var createDriver = async (browser) => {
|
|
|
114
114
|
// src/utils/elementIsNotPresent.ts
|
|
115
115
|
var import_selenium_webdriver3 = require("selenium-webdriver");
|
|
116
116
|
var elementIsNotPresent = function elementIsNotPresent2(locator) {
|
|
117
|
-
return new import_selenium_webdriver3.Condition("for no element to be located " + locator, function(driver) {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
});
|
|
117
|
+
return new import_selenium_webdriver3.Condition("for no element to be located " + locator, async function(driver) {
|
|
118
|
+
const elements = await driver.findElements(locator);
|
|
119
|
+
return elements.length == 0;
|
|
121
120
|
});
|
|
122
121
|
};
|
|
123
122
|
|
|
@@ -162,18 +161,33 @@ var SubsystemsPanel = class extends AbstractElement {
|
|
|
162
161
|
};
|
|
163
162
|
|
|
164
163
|
// src/pageObjects/elements/Forms/AbstractForm.ts
|
|
164
|
+
var import_selenium_webdriver5 = require("selenium-webdriver");
|
|
165
165
|
var AbstractForm = class extends AbstractPage {
|
|
166
166
|
containerBy;
|
|
167
|
+
popupContainerBy;
|
|
167
168
|
constructor(driver) {
|
|
168
169
|
super(driver);
|
|
169
170
|
this.containerBy = byTestId(`form-content-wrapper-${this.formName}`);
|
|
170
171
|
}
|
|
172
|
+
async isModal() {
|
|
173
|
+
const el = await this.getContainerElement();
|
|
174
|
+
const value = await el.getAttribute("data-ismodal");
|
|
175
|
+
return value === "true";
|
|
176
|
+
}
|
|
171
177
|
getContainerElement = () => {
|
|
172
178
|
return this.driver.findElement(this.containerBy);
|
|
173
179
|
};
|
|
174
180
|
get formName() {
|
|
175
181
|
return "";
|
|
176
182
|
}
|
|
183
|
+
/**
|
|
184
|
+
* Возвращает true если форма есть в DOM
|
|
185
|
+
* @example
|
|
186
|
+
* class MyForm extends FormEdit {}
|
|
187
|
+
* //...
|
|
188
|
+
* const formEdit = new MyForm();
|
|
189
|
+
* expect(await formEdit.exists()).toBe(true);
|
|
190
|
+
*/
|
|
177
191
|
async exists() {
|
|
178
192
|
try {
|
|
179
193
|
await this.driver.wait(elementIsNotPresent(this.containerBy), 1e3);
|
|
@@ -182,13 +196,30 @@ var AbstractForm = class extends AbstractPage {
|
|
|
182
196
|
return true;
|
|
183
197
|
}
|
|
184
198
|
}
|
|
199
|
+
/**
|
|
200
|
+
* Получение заголовка на формы
|
|
201
|
+
* @example
|
|
202
|
+
* const listForm = new MyForm();
|
|
203
|
+
* //...
|
|
204
|
+
* expect(await listForm.getTitleText()).toBe('MyFormTitle');
|
|
205
|
+
*/
|
|
206
|
+
async getTitleText() {
|
|
207
|
+
if (await this.isModal()) {
|
|
208
|
+
const popupEl = await this.driver.findElement(this.popupContainerBy);
|
|
209
|
+
const titleEl2 = await popupEl.findElement(import_selenium_webdriver5.By.className("popup-title"));
|
|
210
|
+
return titleEl2.getText();
|
|
211
|
+
}
|
|
212
|
+
let container = await this.getContainerElement();
|
|
213
|
+
let titleEl = await container.findElement(import_selenium_webdriver5.By.className("form-toolbar-name-container"));
|
|
214
|
+
return titleEl.getText();
|
|
215
|
+
}
|
|
185
216
|
};
|
|
186
217
|
|
|
187
218
|
// src/pageObjects/elements/Forms/FormEdit.ts
|
|
188
|
-
var
|
|
219
|
+
var import_selenium_webdriver8 = require("selenium-webdriver");
|
|
189
220
|
|
|
190
221
|
// src/pageObjects/elements/Editors/AbstractEditor.ts
|
|
191
|
-
var
|
|
222
|
+
var import_selenium_webdriver6 = require("selenium-webdriver");
|
|
192
223
|
|
|
193
224
|
// src/pageObjects/AbstractFormElement.ts
|
|
194
225
|
var AbstractFormElement = class extends AbstractElementWithParent {
|
|
@@ -202,7 +233,7 @@ var AbstractFormElement = class extends AbstractElementWithParent {
|
|
|
202
233
|
var AbstractDXEditorWithInput = class extends AbstractFormElement {
|
|
203
234
|
async getInputElement() {
|
|
204
235
|
const controlEl = await this.getElement();
|
|
205
|
-
return controlEl.findElement(
|
|
236
|
+
return controlEl.findElement(import_selenium_webdriver6.By.className("dx-texteditor-input"));
|
|
206
237
|
}
|
|
207
238
|
async getInputValue() {
|
|
208
239
|
const inputEl = await this.getInputElement();
|
|
@@ -211,7 +242,7 @@ var AbstractDXEditorWithInput = class extends AbstractFormElement {
|
|
|
211
242
|
async setInputValue(value) {
|
|
212
243
|
const inputEl = await this.getInputElement();
|
|
213
244
|
await inputEl.click();
|
|
214
|
-
await inputEl.sendKeys(value,
|
|
245
|
+
await inputEl.sendKeys(value, import_selenium_webdriver6.Key.ENTER);
|
|
215
246
|
}
|
|
216
247
|
};
|
|
217
248
|
|
|
@@ -236,6 +267,67 @@ var NumberEditor = class extends AbstractDXEditorWithInput {
|
|
|
236
267
|
}
|
|
237
268
|
};
|
|
238
269
|
|
|
270
|
+
// src/pageObjects/elements/Editors/CheckBox.ts
|
|
271
|
+
var CheckBox = class extends AbstractFormElement {
|
|
272
|
+
async getValue() {
|
|
273
|
+
const inputEl = await this.getElement();
|
|
274
|
+
const result = await inputEl.getAttribute("aria-checked");
|
|
275
|
+
if (result === "true")
|
|
276
|
+
return true;
|
|
277
|
+
if (result === "false")
|
|
278
|
+
return false;
|
|
279
|
+
return void 0;
|
|
280
|
+
}
|
|
281
|
+
async setValue(value) {
|
|
282
|
+
const inputEl = await this.getElement();
|
|
283
|
+
const currentValue = await this.getValue();
|
|
284
|
+
if (currentValue !== value) {
|
|
285
|
+
await inputEl.click();
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
// src/pageObjects/elements/Editors/SelectBoxEditor.ts
|
|
291
|
+
var import_selenium_webdriver7 = require("selenium-webdriver");
|
|
292
|
+
|
|
293
|
+
// src/utils/xpathHelper.ts
|
|
294
|
+
var XPathHelper = class {
|
|
295
|
+
static getRoleXpath(role) {
|
|
296
|
+
return `//div[@role='${role}']`;
|
|
297
|
+
}
|
|
298
|
+
static getClassAndValueXpath(cssClass, value) {
|
|
299
|
+
return `//div[contains(@class, '${cssClass}') and contains(.,'${value}')]`;
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
// src/pageObjects/elements/Editors/SelectBoxEditor.ts
|
|
304
|
+
var SELECT_BOX_OPTION_TEXT_CONTAINER_CLASS = "d5-multi-select-item";
|
|
305
|
+
var SELECT_BOX_ELEMENT_ROLE = "option";
|
|
306
|
+
var SelectBoxEditor = class extends AbstractDXEditorWithInput {
|
|
307
|
+
async setSelectInputValue(value) {
|
|
308
|
+
const inputEl = await this.getInputElement();
|
|
309
|
+
await inputEl.click();
|
|
310
|
+
await inputEl.sendKeys(value, import_selenium_webdriver7.Key.ENTER);
|
|
311
|
+
const combinedValueXpath = XPathHelper.getRoleXpath(SELECT_BOX_ELEMENT_ROLE) + XPathHelper.getClassAndValueXpath(SELECT_BOX_OPTION_TEXT_CONTAINER_CLASS, value);
|
|
312
|
+
await this.driver.wait(async () => {
|
|
313
|
+
try {
|
|
314
|
+
const optElement = await inputEl.findElement(import_selenium_webdriver7.By.xpath(combinedValueXpath));
|
|
315
|
+
await optElement.click();
|
|
316
|
+
return true;
|
|
317
|
+
} catch (e) {
|
|
318
|
+
return false;
|
|
319
|
+
}
|
|
320
|
+
}, 2e3);
|
|
321
|
+
}
|
|
322
|
+
async getValue() {
|
|
323
|
+
const value = await super.getInputValue();
|
|
324
|
+
return value == "" ? null : value;
|
|
325
|
+
}
|
|
326
|
+
setValue(value) {
|
|
327
|
+
return this.setSelectInputValue(value);
|
|
328
|
+
}
|
|
329
|
+
};
|
|
330
|
+
|
|
239
331
|
// src/pageObjects/elements/Editors/editorFactory.ts
|
|
240
332
|
var editorFactory = async (getParentElement, elementBy, driver) => {
|
|
241
333
|
const elementInstance = new AbstractFormElement(getParentElement, elementBy, driver);
|
|
@@ -245,6 +337,10 @@ var editorFactory = async (getParentElement, elementBy, driver) => {
|
|
|
245
337
|
return new TextEditor(getParentElement, elementBy, driver);
|
|
246
338
|
if (classSting.includes("number-control"))
|
|
247
339
|
return new NumberEditor(getParentElement, elementBy, driver);
|
|
340
|
+
if (classSting.includes("check-box"))
|
|
341
|
+
return new CheckBox(getParentElement, elementBy, driver);
|
|
342
|
+
if (classSting.includes("select-control"))
|
|
343
|
+
return new SelectBoxEditor(getParentElement, elementBy, driver);
|
|
248
344
|
throw new Error("Unknown type of editor. Please write ticket to the support");
|
|
249
345
|
};
|
|
250
346
|
|
|
@@ -255,6 +351,9 @@ function createDataTestId(formName, itemType, itemName) {
|
|
|
255
351
|
function createFieldTestId(formName, itemName) {
|
|
256
352
|
return createDataTestId(formName, "form_field" /* FORM_FIELD */, itemName);
|
|
257
353
|
}
|
|
354
|
+
function createTableId(formName) {
|
|
355
|
+
return `${"table" /* TABLE */}-${formName}`;
|
|
356
|
+
}
|
|
258
357
|
|
|
259
358
|
// src/pageObjects/elements/FormField.ts
|
|
260
359
|
var FormField = class extends AbstractElementWithParent {
|
|
@@ -268,10 +367,22 @@ var FormField = class extends AbstractElementWithParent {
|
|
|
268
367
|
this.editor = await editorFactory(this.getParentElement, this.elementBy, this.driver);
|
|
269
368
|
}
|
|
270
369
|
}
|
|
370
|
+
/**
|
|
371
|
+
* Возвращает значение в поле
|
|
372
|
+
* @example
|
|
373
|
+
* expect(await formEdit.field('NumberFld').getValue()).toBe(10);
|
|
374
|
+
* expect(await formEdit.field('TextFld').getValue()).toBe('TestValue');
|
|
375
|
+
*/
|
|
271
376
|
async getValue() {
|
|
272
377
|
await this.initEditor();
|
|
273
378
|
return this.editor.getValue();
|
|
274
379
|
}
|
|
380
|
+
/**
|
|
381
|
+
* Устанавливает значение в поле
|
|
382
|
+
* @example
|
|
383
|
+
* await formEdit.field('NumberFld').setValue(123);
|
|
384
|
+
* await formEdit.field('TextFld').setValue('TestValue');
|
|
385
|
+
*/
|
|
275
386
|
async setValue(value) {
|
|
276
387
|
await this.initEditor();
|
|
277
388
|
return this.editor.setValue(value);
|
|
@@ -280,21 +391,284 @@ var FormField = class extends AbstractElementWithParent {
|
|
|
280
391
|
|
|
281
392
|
// src/pageObjects/elements/Forms/FormEdit.ts
|
|
282
393
|
var FormEdit = class extends AbstractForm {
|
|
283
|
-
saveButtonBy =
|
|
394
|
+
saveButtonBy = import_selenium_webdriver8.By.id("button-save");
|
|
395
|
+
constructor(driver) {
|
|
396
|
+
super(driver);
|
|
397
|
+
this.popupContainerBy = import_selenium_webdriver8.By.className(`popup form-edit-${this.formName}`);
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* Находит поле формы редактирования по имени
|
|
401
|
+
* @example
|
|
402
|
+
* const formEdit = new MyForm();
|
|
403
|
+
* //...
|
|
404
|
+
* expect(await formEdit.field('Name').getValue()).toBe('test value');
|
|
405
|
+
*/
|
|
284
406
|
field(name) {
|
|
285
407
|
return new FormField(this.getContainerElement, this.formName, name, this.driver);
|
|
286
408
|
}
|
|
409
|
+
/**
|
|
410
|
+
* Нажатие на кнопку Сохранить
|
|
411
|
+
* @example
|
|
412
|
+
* const formEdit = new MyForm();
|
|
413
|
+
* //...
|
|
414
|
+
* await formEdit.saveButtonClick();
|
|
415
|
+
*/
|
|
287
416
|
async saveButtonClick() {
|
|
288
417
|
await this.driver.findElement(this.saveButtonBy).click();
|
|
289
418
|
}
|
|
290
419
|
};
|
|
291
420
|
|
|
292
421
|
// src/pageObjects/elements/Forms/ListForm.ts
|
|
293
|
-
var
|
|
422
|
+
var import_selenium_webdriver14 = require("selenium-webdriver");
|
|
423
|
+
|
|
424
|
+
// src/pageObjects/elements/Table/Table.ts
|
|
425
|
+
var import_selenium_webdriver11 = require("selenium-webdriver");
|
|
426
|
+
|
|
427
|
+
// src/pageObjects/elements/Table/utils.ts
|
|
428
|
+
var import_selenium_webdriver9 = require("selenium-webdriver");
|
|
429
|
+
var getRowPathByIndex = (index) => {
|
|
430
|
+
return import_selenium_webdriver9.By.xpath(`//tr[@aria-rowindex="${transformInputIndex(index)}"]`);
|
|
431
|
+
};
|
|
432
|
+
var getColumnPathByIndex = (index) => {
|
|
433
|
+
return import_selenium_webdriver9.By.xpath(`//td[@aria-colindex="${transformInputIndex(index)}"]`);
|
|
434
|
+
};
|
|
435
|
+
var getColumnPathByCaption = (caption) => {
|
|
436
|
+
return import_selenium_webdriver9.By.xpath(`//td[@role="columnheader"][@aria-label="Column ${caption}"]`);
|
|
437
|
+
};
|
|
438
|
+
var getCellPathByIndex = (index) => {
|
|
439
|
+
return import_selenium_webdriver9.By.xpath(`//td[@role="gridcell"][@aria-colindex="${transformInputIndex(index)}"]`);
|
|
440
|
+
};
|
|
441
|
+
var transformInputIndex = (index) => index + 1;
|
|
442
|
+
var transformOutputIndex = (index) => +index - 1;
|
|
443
|
+
|
|
444
|
+
// src/pageObjects/elements/Table/elements/Row.ts
|
|
445
|
+
var import_selenium_webdriver10 = require("selenium-webdriver");
|
|
446
|
+
|
|
447
|
+
// src/pageObjects/elements/Table/elements/Cell.ts
|
|
448
|
+
var Cell = class extends AbstractElementWithParent {
|
|
449
|
+
index;
|
|
450
|
+
constructor(getParentElement, index, driver) {
|
|
451
|
+
super(getParentElement, driver);
|
|
452
|
+
this.index = index;
|
|
453
|
+
this.elementBy = getCellPathByIndex(index);
|
|
454
|
+
}
|
|
455
|
+
async getValue() {
|
|
456
|
+
const cellEl = await this.getElement();
|
|
457
|
+
return cellEl.getText();
|
|
458
|
+
}
|
|
459
|
+
getIndex() {
|
|
460
|
+
return this.index;
|
|
461
|
+
}
|
|
462
|
+
};
|
|
463
|
+
|
|
464
|
+
// src/pageObjects/elements/Table/elements/Row.ts
|
|
465
|
+
var Row = class extends AbstractElementWithParent {
|
|
466
|
+
index;
|
|
467
|
+
getColumnByCaption;
|
|
468
|
+
constructor(getParentElement, index, driver, getColumnByCaption) {
|
|
469
|
+
super(getParentElement, driver);
|
|
470
|
+
this.index = index;
|
|
471
|
+
this.elementBy = getRowPathByIndex(index);
|
|
472
|
+
this.getColumnByCaption = getColumnByCaption;
|
|
473
|
+
}
|
|
474
|
+
getRowElement = () => {
|
|
475
|
+
return this.driver.findElement(this.elementBy);
|
|
476
|
+
};
|
|
477
|
+
async getCellByIndex(index) {
|
|
478
|
+
const rowEl = await this.getElement();
|
|
479
|
+
const cell = rowEl.findElement(getCellPathByIndex(index));
|
|
480
|
+
if (cell) {
|
|
481
|
+
return new Cell(this.getRowElement, index, this.driver);
|
|
482
|
+
}
|
|
483
|
+
throw new Error(`Cannot find cell by index: ${index}`);
|
|
484
|
+
}
|
|
485
|
+
async getCell(caption) {
|
|
486
|
+
const column = await this.getColumnByCaption(caption);
|
|
487
|
+
if (column) {
|
|
488
|
+
const index = column.getIndex();
|
|
489
|
+
return this.getCellByIndex(index);
|
|
490
|
+
}
|
|
491
|
+
throw new Error("Unknown caption of cell");
|
|
492
|
+
}
|
|
493
|
+
async select() {
|
|
494
|
+
const rowEl = await this.getElement();
|
|
495
|
+
await rowEl.click();
|
|
496
|
+
}
|
|
497
|
+
async isSelected() {
|
|
498
|
+
const rowEl = await this.getElement();
|
|
499
|
+
const result = await rowEl.getAttribute("aria-selected");
|
|
500
|
+
return result === "true";
|
|
501
|
+
}
|
|
502
|
+
getIndex() {
|
|
503
|
+
return this.index;
|
|
504
|
+
}
|
|
505
|
+
async getCells() {
|
|
506
|
+
const rowEl = await this.getElement();
|
|
507
|
+
const cells = await rowEl.findElements(import_selenium_webdriver10.By.css(`td[role="gridcell"]`));
|
|
508
|
+
const result = [];
|
|
509
|
+
cells.forEach((_, index) => {
|
|
510
|
+
const newCell = new Cell(this.getRowElement, index, this.driver);
|
|
511
|
+
result.push(newCell);
|
|
512
|
+
});
|
|
513
|
+
return result;
|
|
514
|
+
}
|
|
515
|
+
};
|
|
516
|
+
|
|
517
|
+
// src/pageObjects/elements/Table/elements/Column.ts
|
|
518
|
+
var Column = class extends AbstractElementWithParent {
|
|
519
|
+
index;
|
|
520
|
+
constructor(getParentElement, index, driver) {
|
|
521
|
+
super(getParentElement, driver);
|
|
522
|
+
this.index = index;
|
|
523
|
+
this.elementBy = getColumnPathByIndex(index);
|
|
524
|
+
}
|
|
525
|
+
async caption() {
|
|
526
|
+
const el = await this.getElement();
|
|
527
|
+
return el.getText();
|
|
528
|
+
}
|
|
529
|
+
getIndex() {
|
|
530
|
+
return this.index;
|
|
531
|
+
}
|
|
532
|
+
};
|
|
533
|
+
|
|
534
|
+
// src/pageObjects/elements/Table/Table.ts
|
|
535
|
+
var Table = class extends AbstractElementWithParent {
|
|
536
|
+
constructor(getParentElement, formName, driver) {
|
|
537
|
+
super(getParentElement, driver);
|
|
538
|
+
this.elementBy = import_selenium_webdriver11.By.id(createTableId(formName));
|
|
539
|
+
}
|
|
540
|
+
async getHeaderElement() {
|
|
541
|
+
const parentEl = await this.getElement();
|
|
542
|
+
return parentEl.findElement(import_selenium_webdriver11.By.className("dx-header-row"));
|
|
543
|
+
}
|
|
544
|
+
async getDataGrid() {
|
|
545
|
+
const parentEl = await this.getElement();
|
|
546
|
+
return parentEl.findElement(import_selenium_webdriver11.By.css(`div[role="grid"]`));
|
|
547
|
+
}
|
|
548
|
+
getTableElement = () => {
|
|
549
|
+
return this.driver.findElement(this.elementBy);
|
|
550
|
+
};
|
|
551
|
+
async getRowByIndex(index) {
|
|
552
|
+
const gridContainer = await this.getDataGrid();
|
|
553
|
+
const row = await gridContainer.findElement(getRowPathByIndex(index));
|
|
554
|
+
if (row) {
|
|
555
|
+
return new Row(this.getTableElement, index, this.driver, this.getColumnByCaption.bind(this));
|
|
556
|
+
}
|
|
557
|
+
throw new Error(`Cannot find row by index: ${index}`);
|
|
558
|
+
}
|
|
559
|
+
async getColumnByIndex(index) {
|
|
560
|
+
const headerContainer = await this.getHeaderElement();
|
|
561
|
+
const column = await headerContainer.findElement(getColumnPathByIndex(index));
|
|
562
|
+
if (column) {
|
|
563
|
+
return new Column(this.getTableElement, index, this.driver);
|
|
564
|
+
}
|
|
565
|
+
throw new Error(`Cannot find column by index: ${index}`);
|
|
566
|
+
}
|
|
567
|
+
async getColumnByCaption(caption) {
|
|
568
|
+
const headerContainer = await this.getHeaderElement();
|
|
569
|
+
const column = await headerContainer.findElement(getColumnPathByCaption(caption));
|
|
570
|
+
if (column) {
|
|
571
|
+
const index = await column.getAttribute("aria-colindex");
|
|
572
|
+
return new Column(this.getTableElement, transformOutputIndex(index), this.driver);
|
|
573
|
+
}
|
|
574
|
+
throw new Error(`Cannot find column by caption: ${caption}`);
|
|
575
|
+
}
|
|
576
|
+
async selectRowByIndex(index) {
|
|
577
|
+
const row = await this.getRowByIndex(index);
|
|
578
|
+
if (row) {
|
|
579
|
+
await row.select();
|
|
580
|
+
} else {
|
|
581
|
+
throw new Error(`Cannot find row by index: ${index}`);
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
async getRows() {
|
|
585
|
+
const gridContainer = await this.getDataGrid();
|
|
586
|
+
const rows = await gridContainer.findElements(import_selenium_webdriver11.By.className("dx-row dx-data-row"));
|
|
587
|
+
const result = [];
|
|
588
|
+
rows.forEach((_, index) => {
|
|
589
|
+
const newRow = new Row(this.getTableElement, index, this.driver, this.getColumnByCaption.bind(this));
|
|
590
|
+
result.push(newRow);
|
|
591
|
+
});
|
|
592
|
+
return result;
|
|
593
|
+
}
|
|
594
|
+
async getColumns() {
|
|
595
|
+
const headerContainer = await this.getHeaderElement();
|
|
596
|
+
const columns = await headerContainer.findElements(import_selenium_webdriver11.By.css(`td[role="columnheader"]`));
|
|
597
|
+
const result = [];
|
|
598
|
+
columns.forEach((_, index) => {
|
|
599
|
+
const newCol = new Column(this.getTableElement, index, this.driver);
|
|
600
|
+
result.push(newCol);
|
|
601
|
+
});
|
|
602
|
+
return result;
|
|
603
|
+
}
|
|
604
|
+
async element() {
|
|
605
|
+
return this.getElement();
|
|
606
|
+
}
|
|
607
|
+
};
|
|
608
|
+
|
|
609
|
+
// src/pageObjects/elements/TableToolbar/TableToolbar.ts
|
|
610
|
+
var import_selenium_webdriver13 = require("selenium-webdriver");
|
|
611
|
+
|
|
612
|
+
// src/pageObjects/elements/TableToolbar/TableToolbarButton.ts
|
|
613
|
+
var import_selenium_webdriver12 = require("selenium-webdriver");
|
|
614
|
+
var TOOLBAR_BUTTON_CLASS = "toolbar-button";
|
|
615
|
+
var TableToolbarButton = class extends AbstractElementWithParent {
|
|
616
|
+
constructor(getParentElement, name, driver) {
|
|
617
|
+
super(getParentElement, driver);
|
|
618
|
+
this.elementBy = import_selenium_webdriver12.By.id(`${TOOLBAR_BUTTON_CLASS}-${name}`);
|
|
619
|
+
}
|
|
620
|
+
async click() {
|
|
621
|
+
const button = await this.getElement();
|
|
622
|
+
return button.click();
|
|
623
|
+
}
|
|
624
|
+
};
|
|
625
|
+
|
|
626
|
+
// src/pageObjects/elements/TableToolbar/TableToolbar.ts
|
|
627
|
+
var TABLE_TOOLBAR_CLASS = "d5-table-toolbar";
|
|
628
|
+
var TableToolbar = class extends AbstractElementWithParent {
|
|
629
|
+
constructor(getParentElement, formName, driver) {
|
|
630
|
+
super(getParentElement, driver);
|
|
631
|
+
this.elementBy = import_selenium_webdriver13.By.id(`${TABLE_TOOLBAR_CLASS}-${formName}`);
|
|
632
|
+
}
|
|
633
|
+
getTableToolbarElement = () => {
|
|
634
|
+
return this.driver.findElement(this.elementBy);
|
|
635
|
+
};
|
|
636
|
+
async button(name) {
|
|
637
|
+
const toolbar = await this.getTableToolbarElement();
|
|
638
|
+
const button = await toolbar.findElement(import_selenium_webdriver13.By.id(`${TOOLBAR_BUTTON_CLASS}-${name}`));
|
|
639
|
+
if (button) {
|
|
640
|
+
return new TableToolbarButton(this.getTableToolbarElement, name, this.driver);
|
|
641
|
+
}
|
|
642
|
+
throw new Error(`Cannot find button by name: ${name}`);
|
|
643
|
+
}
|
|
644
|
+
};
|
|
645
|
+
|
|
646
|
+
// src/pageObjects/elements/Forms/ListForm.ts
|
|
294
647
|
var ListForm = class extends AbstractForm {
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
648
|
+
constructor(driver) {
|
|
649
|
+
super(driver);
|
|
650
|
+
this.popupContainerBy = import_selenium_webdriver14.By.className(`popup form-inline-${this.formName}`);
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* Находит таблицу
|
|
654
|
+
* @example
|
|
655
|
+
* const listForm = new MyForm();
|
|
656
|
+
* //...
|
|
657
|
+
* expect(listForm.table());
|
|
658
|
+
*/
|
|
659
|
+
table() {
|
|
660
|
+
return new Table(this.getContainerElement, this.formName, this.driver);
|
|
661
|
+
}
|
|
662
|
+
/**
|
|
663
|
+
* Находит таблицу
|
|
664
|
+
* @example
|
|
665
|
+
* const listForm = new MyForm();
|
|
666
|
+
* //...
|
|
667
|
+
* expect(listForm.toolbarButton());
|
|
668
|
+
*/
|
|
669
|
+
toolbarButton(name) {
|
|
670
|
+
const toolbar = new TableToolbar(this.getContainerElement, this.formName, this.driver);
|
|
671
|
+
return toolbar.button(name);
|
|
298
672
|
}
|
|
299
673
|
};
|
|
300
674
|
|
|
@@ -76,10 +76,28 @@ declare class SubsystemsPanel extends AbstractElement {
|
|
|
76
76
|
|
|
77
77
|
declare abstract class AbstractForm extends AbstractPage {
|
|
78
78
|
protected containerBy: By;
|
|
79
|
-
|
|
79
|
+
protected popupContainerBy: By;
|
|
80
|
+
protected constructor(driver?: WebDriver);
|
|
81
|
+
protected isModal(): Promise<boolean>;
|
|
80
82
|
protected getContainerElement: () => selenium_webdriver.WebElementPromise;
|
|
81
83
|
protected get formName(): string;
|
|
84
|
+
/**
|
|
85
|
+
* Возвращает true если форма есть в DOM
|
|
86
|
+
* @example
|
|
87
|
+
* class MyForm extends FormEdit {}
|
|
88
|
+
* //...
|
|
89
|
+
* const formEdit = new MyForm();
|
|
90
|
+
* expect(await formEdit.exists()).toBe(true);
|
|
91
|
+
*/
|
|
82
92
|
exists(): Promise<boolean>;
|
|
93
|
+
/**
|
|
94
|
+
* Получение заголовка на формы
|
|
95
|
+
* @example
|
|
96
|
+
* const listForm = new MyForm();
|
|
97
|
+
* //...
|
|
98
|
+
* expect(await listForm.getTitleText()).toBe('MyFormTitle');
|
|
99
|
+
*/
|
|
100
|
+
getTitleText(): Promise<string>;
|
|
83
101
|
}
|
|
84
102
|
|
|
85
103
|
declare abstract class AbstractElementWithParent extends AbstractElement {
|
|
@@ -122,19 +140,107 @@ declare class FormField extends AbstractElementWithParent implements Editor {
|
|
|
122
140
|
editor: Editor;
|
|
123
141
|
constructor(getParentElement: () => WebElementPromise, formName: string, name: string, driver?: WebDriver);
|
|
124
142
|
private initEditor;
|
|
143
|
+
/**
|
|
144
|
+
* Возвращает значение в поле
|
|
145
|
+
* @example
|
|
146
|
+
* expect(await formEdit.field('NumberFld').getValue()).toBe(10);
|
|
147
|
+
* expect(await formEdit.field('TextFld').getValue()).toBe('TestValue');
|
|
148
|
+
*/
|
|
125
149
|
getValue(): Promise<any>;
|
|
150
|
+
/**
|
|
151
|
+
* Устанавливает значение в поле
|
|
152
|
+
* @example
|
|
153
|
+
* await formEdit.field('NumberFld').setValue(123);
|
|
154
|
+
* await formEdit.field('TextFld').setValue('TestValue');
|
|
155
|
+
*/
|
|
126
156
|
setValue(value: any): Promise<void>;
|
|
127
157
|
}
|
|
128
158
|
|
|
129
159
|
declare abstract class FormEdit extends AbstractForm {
|
|
130
160
|
saveButtonBy: By;
|
|
161
|
+
protected constructor(driver?: WebDriver);
|
|
162
|
+
/**
|
|
163
|
+
* Находит поле формы редактирования по имени
|
|
164
|
+
* @example
|
|
165
|
+
* const formEdit = new MyForm();
|
|
166
|
+
* //...
|
|
167
|
+
* expect(await formEdit.field('Name').getValue()).toBe('test value');
|
|
168
|
+
*/
|
|
131
169
|
field(name: string): FormField;
|
|
170
|
+
/**
|
|
171
|
+
* Нажатие на кнопку Сохранить
|
|
172
|
+
* @example
|
|
173
|
+
* const formEdit = new MyForm();
|
|
174
|
+
* //...
|
|
175
|
+
* await formEdit.saveButtonClick();
|
|
176
|
+
*/
|
|
132
177
|
saveButtonClick(): Promise<void>;
|
|
133
178
|
}
|
|
134
179
|
|
|
180
|
+
declare class TableToolbarButton extends AbstractElementWithParent {
|
|
181
|
+
constructor(getParentElement: () => WebElementPromise, name: string, driver?: WebDriver);
|
|
182
|
+
click(): Promise<void>;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
declare class Cell extends AbstractElementWithParent {
|
|
186
|
+
index: number;
|
|
187
|
+
constructor(getParentElement: () => WebElementPromise, index: number, driver?: WebDriver);
|
|
188
|
+
getValue(): Promise<string>;
|
|
189
|
+
getIndex(): number;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
declare class Column extends AbstractElementWithParent {
|
|
193
|
+
index: number;
|
|
194
|
+
constructor(getParentElement: () => WebElementPromise, index: number, driver?: WebDriver);
|
|
195
|
+
caption(): Promise<string>;
|
|
196
|
+
getIndex(): number;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
declare class Row extends AbstractElementWithParent {
|
|
200
|
+
index: number;
|
|
201
|
+
protected getColumnByCaption: (caption: string) => Promise<Column>;
|
|
202
|
+
constructor(getParentElement: () => WebElementPromise, index: number, driver?: WebDriver, getColumnByCaption?: (caption: string) => Promise<Column>);
|
|
203
|
+
protected getRowElement: () => WebElementPromise;
|
|
204
|
+
getCellByIndex(index: number): Promise<Cell>;
|
|
205
|
+
getCell(caption: string): Promise<Cell>;
|
|
206
|
+
select(): Promise<void>;
|
|
207
|
+
isSelected(): Promise<boolean>;
|
|
208
|
+
getIndex(): number;
|
|
209
|
+
getCells(): Promise<Cell[]>;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
declare class Table extends AbstractElementWithParent {
|
|
213
|
+
constructor(getParentElement: () => WebElementPromise, formName: string, driver?: WebDriver);
|
|
214
|
+
protected getHeaderElement(): Promise<selenium_webdriver.WebElement>;
|
|
215
|
+
protected getDataGrid(): Promise<selenium_webdriver.WebElement>;
|
|
216
|
+
protected getTableElement: () => WebElementPromise;
|
|
217
|
+
getRowByIndex(index: number): Promise<Row>;
|
|
218
|
+
getColumnByIndex(index: number): Promise<Column>;
|
|
219
|
+
getColumnByCaption(caption: string): Promise<Column>;
|
|
220
|
+
selectRowByIndex(index: number): Promise<void>;
|
|
221
|
+
getRows(): Promise<Row[]>;
|
|
222
|
+
getColumns(): Promise<Column[]>;
|
|
223
|
+
element(): Promise<selenium_webdriver.WebElement>;
|
|
224
|
+
}
|
|
225
|
+
|
|
135
226
|
declare abstract class ListForm extends AbstractForm {
|
|
136
|
-
|
|
137
|
-
|
|
227
|
+
protected constructor(driver?: WebDriver);
|
|
228
|
+
/**
|
|
229
|
+
* Находит таблицу
|
|
230
|
+
* @example
|
|
231
|
+
* const listForm = new MyForm();
|
|
232
|
+
* //...
|
|
233
|
+
* expect(listForm.table());
|
|
234
|
+
*/
|
|
235
|
+
table(): Table;
|
|
236
|
+
/**
|
|
237
|
+
* Находит таблицу
|
|
238
|
+
* @example
|
|
239
|
+
* const listForm = new MyForm();
|
|
240
|
+
* //...
|
|
241
|
+
* expect(listForm.toolbarButton());
|
|
242
|
+
*/
|
|
243
|
+
toolbarButton(name: string): Promise<TableToolbarButton>;
|
|
138
244
|
}
|
|
139
245
|
|
|
140
246
|
export { AbstractPage, Editor, FormEdit, FormField, ListForm, LoginPage, NumberEditor, SubsystemsPanel, TextEditor, byTestId, config, createDriver, editorFactory, elementIsNotPresent, signIn };
|