d5-testing-library 1.0.0 → 1.0.2
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 +380 -13
- package/dist/d5-testing-library.d.ts +109 -3
- package/dist/d5-testing-library.legacy-esm.js +379 -12
- package/dist/d5-testing-library.mjs +379 -12
- package/package.json +3 -3
|
@@ -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,60 @@ 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
|
+
const optElement = await inputEl.findElement(import_selenium_webdriver7.By.xpath(combinedValueXpath));
|
|
313
|
+
await optElement.click();
|
|
314
|
+
}
|
|
315
|
+
async getValue() {
|
|
316
|
+
const value = await super.getInputValue();
|
|
317
|
+
return value == "" ? null : value;
|
|
318
|
+
}
|
|
319
|
+
setValue(value) {
|
|
320
|
+
return this.setSelectInputValue(value);
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
|
|
239
324
|
// src/pageObjects/elements/Editors/editorFactory.ts
|
|
240
325
|
var editorFactory = async (getParentElement, elementBy, driver) => {
|
|
241
326
|
const elementInstance = new AbstractFormElement(getParentElement, elementBy, driver);
|
|
@@ -245,6 +330,10 @@ var editorFactory = async (getParentElement, elementBy, driver) => {
|
|
|
245
330
|
return new TextEditor(getParentElement, elementBy, driver);
|
|
246
331
|
if (classSting.includes("number-control"))
|
|
247
332
|
return new NumberEditor(getParentElement, elementBy, driver);
|
|
333
|
+
if (classSting.includes("check-box"))
|
|
334
|
+
return new CheckBox(getParentElement, elementBy, driver);
|
|
335
|
+
if (classSting.includes("select-control"))
|
|
336
|
+
return new SelectBoxEditor(getParentElement, elementBy, driver);
|
|
248
337
|
throw new Error("Unknown type of editor. Please write ticket to the support");
|
|
249
338
|
};
|
|
250
339
|
|
|
@@ -255,6 +344,9 @@ function createDataTestId(formName, itemType, itemName) {
|
|
|
255
344
|
function createFieldTestId(formName, itemName) {
|
|
256
345
|
return createDataTestId(formName, "form_field" /* FORM_FIELD */, itemName);
|
|
257
346
|
}
|
|
347
|
+
function createTableId(formName) {
|
|
348
|
+
return `${"table" /* TABLE */}-${formName}`;
|
|
349
|
+
}
|
|
258
350
|
|
|
259
351
|
// src/pageObjects/elements/FormField.ts
|
|
260
352
|
var FormField = class extends AbstractElementWithParent {
|
|
@@ -268,10 +360,22 @@ var FormField = class extends AbstractElementWithParent {
|
|
|
268
360
|
this.editor = await editorFactory(this.getParentElement, this.elementBy, this.driver);
|
|
269
361
|
}
|
|
270
362
|
}
|
|
363
|
+
/**
|
|
364
|
+
* Возвращает значение в поле
|
|
365
|
+
* @example
|
|
366
|
+
* expect(await formEdit.field('NumberFld').getValue()).toBe(10);
|
|
367
|
+
* expect(await formEdit.field('TextFld').getValue()).toBe('TestValue');
|
|
368
|
+
*/
|
|
271
369
|
async getValue() {
|
|
272
370
|
await this.initEditor();
|
|
273
371
|
return this.editor.getValue();
|
|
274
372
|
}
|
|
373
|
+
/**
|
|
374
|
+
* Устанавливает значение в поле
|
|
375
|
+
* @example
|
|
376
|
+
* await formEdit.field('NumberFld').setValue(123);
|
|
377
|
+
* await formEdit.field('TextFld').setValue('TestValue');
|
|
378
|
+
*/
|
|
275
379
|
async setValue(value) {
|
|
276
380
|
await this.initEditor();
|
|
277
381
|
return this.editor.setValue(value);
|
|
@@ -280,21 +384,284 @@ var FormField = class extends AbstractElementWithParent {
|
|
|
280
384
|
|
|
281
385
|
// src/pageObjects/elements/Forms/FormEdit.ts
|
|
282
386
|
var FormEdit = class extends AbstractForm {
|
|
283
|
-
saveButtonBy =
|
|
387
|
+
saveButtonBy = import_selenium_webdriver8.By.id("button-save");
|
|
388
|
+
constructor(driver) {
|
|
389
|
+
super(driver);
|
|
390
|
+
this.popupContainerBy = import_selenium_webdriver8.By.className(`popup form-edit-${this.formName}`);
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Находит поле формы редактирования по имени
|
|
394
|
+
* @example
|
|
395
|
+
* const formEdit = new MyForm();
|
|
396
|
+
* //...
|
|
397
|
+
* expect(await formEdit.field('Name').getValue()).toBe('test value');
|
|
398
|
+
*/
|
|
284
399
|
field(name) {
|
|
285
400
|
return new FormField(this.getContainerElement, this.formName, name, this.driver);
|
|
286
401
|
}
|
|
402
|
+
/**
|
|
403
|
+
* Нажатие на кнопку Сохранить
|
|
404
|
+
* @example
|
|
405
|
+
* const formEdit = new MyForm();
|
|
406
|
+
* //...
|
|
407
|
+
* await formEdit.saveButtonClick();
|
|
408
|
+
*/
|
|
287
409
|
async saveButtonClick() {
|
|
288
410
|
await this.driver.findElement(this.saveButtonBy).click();
|
|
289
411
|
}
|
|
290
412
|
};
|
|
291
413
|
|
|
292
414
|
// src/pageObjects/elements/Forms/ListForm.ts
|
|
293
|
-
var
|
|
415
|
+
var import_selenium_webdriver14 = require("selenium-webdriver");
|
|
416
|
+
|
|
417
|
+
// src/pageObjects/elements/Table/Table.ts
|
|
418
|
+
var import_selenium_webdriver11 = require("selenium-webdriver");
|
|
419
|
+
|
|
420
|
+
// src/pageObjects/elements/Table/utils.ts
|
|
421
|
+
var import_selenium_webdriver9 = require("selenium-webdriver");
|
|
422
|
+
var getRowPathByIndex = (index) => {
|
|
423
|
+
return import_selenium_webdriver9.By.xpath(`//tr[@aria-rowindex="${transformInputIndex(index)}"]`);
|
|
424
|
+
};
|
|
425
|
+
var getColumnPathByIndex = (index) => {
|
|
426
|
+
return import_selenium_webdriver9.By.xpath(`//td[@aria-colindex="${transformInputIndex(index)}"]`);
|
|
427
|
+
};
|
|
428
|
+
var getColumnPathByCaption = (caption) => {
|
|
429
|
+
return import_selenium_webdriver9.By.xpath(`//td[@role="columnheader"][@aria-label="Column ${caption}"]`);
|
|
430
|
+
};
|
|
431
|
+
var getCellPathByIndex = (index) => {
|
|
432
|
+
return import_selenium_webdriver9.By.xpath(`//td[@role="gridcell"][@aria-colindex="${transformInputIndex(index)}"]`);
|
|
433
|
+
};
|
|
434
|
+
var transformInputIndex = (index) => index + 1;
|
|
435
|
+
var transformOutputIndex = (index) => +index - 1;
|
|
436
|
+
|
|
437
|
+
// src/pageObjects/elements/Table/elements/Row.ts
|
|
438
|
+
var import_selenium_webdriver10 = require("selenium-webdriver");
|
|
439
|
+
|
|
440
|
+
// src/pageObjects/elements/Table/elements/Cell.ts
|
|
441
|
+
var Cell = class extends AbstractElementWithParent {
|
|
442
|
+
index;
|
|
443
|
+
constructor(getParentElement, index, driver) {
|
|
444
|
+
super(getParentElement, driver);
|
|
445
|
+
this.index = index;
|
|
446
|
+
this.elementBy = getCellPathByIndex(index);
|
|
447
|
+
}
|
|
448
|
+
async getValue() {
|
|
449
|
+
const cellEl = await this.getElement();
|
|
450
|
+
return cellEl.getText();
|
|
451
|
+
}
|
|
452
|
+
getIndex() {
|
|
453
|
+
return this.index;
|
|
454
|
+
}
|
|
455
|
+
};
|
|
456
|
+
|
|
457
|
+
// src/pageObjects/elements/Table/elements/Row.ts
|
|
458
|
+
var Row = class extends AbstractElementWithParent {
|
|
459
|
+
index;
|
|
460
|
+
getColumnByCaption;
|
|
461
|
+
constructor(getParentElement, index, driver, getColumnByCaption) {
|
|
462
|
+
super(getParentElement, driver);
|
|
463
|
+
this.index = index;
|
|
464
|
+
this.elementBy = getRowPathByIndex(index);
|
|
465
|
+
this.getColumnByCaption = getColumnByCaption;
|
|
466
|
+
}
|
|
467
|
+
getRowElement = () => {
|
|
468
|
+
return this.driver.findElement(this.elementBy);
|
|
469
|
+
};
|
|
470
|
+
async getCellByIndex(index) {
|
|
471
|
+
const rowEl = await this.getElement();
|
|
472
|
+
const cell = rowEl.findElement(getCellPathByIndex(index));
|
|
473
|
+
if (cell) {
|
|
474
|
+
return new Cell(this.getRowElement, index, this.driver);
|
|
475
|
+
}
|
|
476
|
+
throw new Error(`Cannot find cell by index: ${index}`);
|
|
477
|
+
}
|
|
478
|
+
async getCell(caption) {
|
|
479
|
+
const column = await this.getColumnByCaption(caption);
|
|
480
|
+
if (column) {
|
|
481
|
+
const index = column.getIndex();
|
|
482
|
+
return this.getCellByIndex(index);
|
|
483
|
+
}
|
|
484
|
+
throw new Error("Unknown caption of cell");
|
|
485
|
+
}
|
|
486
|
+
async select() {
|
|
487
|
+
const rowEl = await this.getElement();
|
|
488
|
+
await rowEl.click();
|
|
489
|
+
}
|
|
490
|
+
async isSelected() {
|
|
491
|
+
const rowEl = await this.getElement();
|
|
492
|
+
const result = await rowEl.getAttribute("aria-selected");
|
|
493
|
+
return result === "true";
|
|
494
|
+
}
|
|
495
|
+
getIndex() {
|
|
496
|
+
return this.index;
|
|
497
|
+
}
|
|
498
|
+
async getCells() {
|
|
499
|
+
const rowEl = await this.getElement();
|
|
500
|
+
const cells = await rowEl.findElements(import_selenium_webdriver10.By.css(`td[role="gridcell"]`));
|
|
501
|
+
const result = [];
|
|
502
|
+
cells.forEach((_, index) => {
|
|
503
|
+
const newCell = new Cell(this.getRowElement, index, this.driver);
|
|
504
|
+
result.push(newCell);
|
|
505
|
+
});
|
|
506
|
+
return result;
|
|
507
|
+
}
|
|
508
|
+
};
|
|
509
|
+
|
|
510
|
+
// src/pageObjects/elements/Table/elements/Column.ts
|
|
511
|
+
var Column = class extends AbstractElementWithParent {
|
|
512
|
+
index;
|
|
513
|
+
constructor(getParentElement, index, driver) {
|
|
514
|
+
super(getParentElement, driver);
|
|
515
|
+
this.index = index;
|
|
516
|
+
this.elementBy = getColumnPathByIndex(index);
|
|
517
|
+
}
|
|
518
|
+
async caption() {
|
|
519
|
+
const el = await this.getElement();
|
|
520
|
+
return el.getText();
|
|
521
|
+
}
|
|
522
|
+
getIndex() {
|
|
523
|
+
return this.index;
|
|
524
|
+
}
|
|
525
|
+
};
|
|
526
|
+
|
|
527
|
+
// src/pageObjects/elements/Table/Table.ts
|
|
528
|
+
var Table = class extends AbstractElementWithParent {
|
|
529
|
+
constructor(getParentElement, formName, driver) {
|
|
530
|
+
super(getParentElement, driver);
|
|
531
|
+
this.elementBy = import_selenium_webdriver11.By.id(createTableId(formName));
|
|
532
|
+
}
|
|
533
|
+
async getHeaderElement() {
|
|
534
|
+
const parentEl = await this.getElement();
|
|
535
|
+
return parentEl.findElement(import_selenium_webdriver11.By.className("dx-header-row"));
|
|
536
|
+
}
|
|
537
|
+
async getDataGrid() {
|
|
538
|
+
const parentEl = await this.getElement();
|
|
539
|
+
return parentEl.findElement(import_selenium_webdriver11.By.css(`div[role="grid"]`));
|
|
540
|
+
}
|
|
541
|
+
getTableElement = () => {
|
|
542
|
+
return this.driver.findElement(this.elementBy);
|
|
543
|
+
};
|
|
544
|
+
async getRowByIndex(index) {
|
|
545
|
+
const gridContainer = await this.getDataGrid();
|
|
546
|
+
const row = await gridContainer.findElement(getRowPathByIndex(index));
|
|
547
|
+
if (row) {
|
|
548
|
+
return new Row(this.getTableElement, index, this.driver, this.getColumnByCaption.bind(this));
|
|
549
|
+
}
|
|
550
|
+
throw new Error(`Cannot find row by index: ${index}`);
|
|
551
|
+
}
|
|
552
|
+
async getColumnByIndex(index) {
|
|
553
|
+
const headerContainer = await this.getHeaderElement();
|
|
554
|
+
const column = await headerContainer.findElement(getColumnPathByIndex(index));
|
|
555
|
+
if (column) {
|
|
556
|
+
return new Column(this.getTableElement, index, this.driver);
|
|
557
|
+
}
|
|
558
|
+
throw new Error(`Cannot find column by index: ${index}`);
|
|
559
|
+
}
|
|
560
|
+
async getColumnByCaption(caption) {
|
|
561
|
+
const headerContainer = await this.getHeaderElement();
|
|
562
|
+
const column = await headerContainer.findElement(getColumnPathByCaption(caption));
|
|
563
|
+
if (column) {
|
|
564
|
+
const index = await column.getAttribute("aria-colindex");
|
|
565
|
+
return new Column(this.getTableElement, transformOutputIndex(index), this.driver);
|
|
566
|
+
}
|
|
567
|
+
throw new Error(`Cannot find column by caption: ${caption}`);
|
|
568
|
+
}
|
|
569
|
+
async selectRowByIndex(index) {
|
|
570
|
+
const row = await this.getRowByIndex(index);
|
|
571
|
+
if (row) {
|
|
572
|
+
await row.select();
|
|
573
|
+
} else {
|
|
574
|
+
throw new Error(`Cannot find row by index: ${index}`);
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
async getRows() {
|
|
578
|
+
const gridContainer = await this.getDataGrid();
|
|
579
|
+
const rows = await gridContainer.findElements(import_selenium_webdriver11.By.className("dx-row dx-data-row"));
|
|
580
|
+
const result = [];
|
|
581
|
+
rows.forEach((_, index) => {
|
|
582
|
+
const newRow = new Row(this.getTableElement, index, this.driver, this.getColumnByCaption.bind(this));
|
|
583
|
+
result.push(newRow);
|
|
584
|
+
});
|
|
585
|
+
return result;
|
|
586
|
+
}
|
|
587
|
+
async getColumns() {
|
|
588
|
+
const headerContainer = await this.getHeaderElement();
|
|
589
|
+
const columns = await headerContainer.findElements(import_selenium_webdriver11.By.css(`td[role="columnheader"]`));
|
|
590
|
+
const result = [];
|
|
591
|
+
columns.forEach((_, index) => {
|
|
592
|
+
const newCol = new Column(this.getTableElement, index, this.driver);
|
|
593
|
+
result.push(newCol);
|
|
594
|
+
});
|
|
595
|
+
return result;
|
|
596
|
+
}
|
|
597
|
+
async element() {
|
|
598
|
+
return this.getElement();
|
|
599
|
+
}
|
|
600
|
+
};
|
|
601
|
+
|
|
602
|
+
// src/pageObjects/elements/TableToolbar/TableToolbar.ts
|
|
603
|
+
var import_selenium_webdriver13 = require("selenium-webdriver");
|
|
604
|
+
|
|
605
|
+
// src/pageObjects/elements/TableToolbar/TableToolbarButton.ts
|
|
606
|
+
var import_selenium_webdriver12 = require("selenium-webdriver");
|
|
607
|
+
var TOOLBAR_BUTTON_CLASS = "toolbar-button";
|
|
608
|
+
var TableToolbarButton = class extends AbstractElementWithParent {
|
|
609
|
+
constructor(getParentElement, name, driver) {
|
|
610
|
+
super(getParentElement, driver);
|
|
611
|
+
this.elementBy = import_selenium_webdriver12.By.id(`${TOOLBAR_BUTTON_CLASS}-${name}`);
|
|
612
|
+
}
|
|
613
|
+
async click() {
|
|
614
|
+
const button = await this.getElement();
|
|
615
|
+
return button.click();
|
|
616
|
+
}
|
|
617
|
+
};
|
|
618
|
+
|
|
619
|
+
// src/pageObjects/elements/TableToolbar/TableToolbar.ts
|
|
620
|
+
var TABLE_TOOLBAR_CLASS = "d5-table-toolbar";
|
|
621
|
+
var TableToolbar = class extends AbstractElementWithParent {
|
|
622
|
+
constructor(getParentElement, formName, driver) {
|
|
623
|
+
super(getParentElement, driver);
|
|
624
|
+
this.elementBy = import_selenium_webdriver13.By.id(`${TABLE_TOOLBAR_CLASS}-${formName}`);
|
|
625
|
+
}
|
|
626
|
+
getTableToolbarElement = () => {
|
|
627
|
+
return this.driver.findElement(this.elementBy);
|
|
628
|
+
};
|
|
629
|
+
async button(name) {
|
|
630
|
+
const toolbar = await this.getTableToolbarElement();
|
|
631
|
+
const button = await toolbar.findElement(import_selenium_webdriver13.By.id(`${TOOLBAR_BUTTON_CLASS}-${name}`));
|
|
632
|
+
if (button) {
|
|
633
|
+
return new TableToolbarButton(this.getTableToolbarElement, name, this.driver);
|
|
634
|
+
}
|
|
635
|
+
throw new Error(`Cannot find button by name: ${name}`);
|
|
636
|
+
}
|
|
637
|
+
};
|
|
638
|
+
|
|
639
|
+
// src/pageObjects/elements/Forms/ListForm.ts
|
|
294
640
|
var ListForm = class extends AbstractForm {
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
641
|
+
constructor(driver) {
|
|
642
|
+
super(driver);
|
|
643
|
+
this.popupContainerBy = import_selenium_webdriver14.By.className(`popup form-inline-${this.formName}`);
|
|
644
|
+
}
|
|
645
|
+
/**
|
|
646
|
+
* Находит таблицу
|
|
647
|
+
* @example
|
|
648
|
+
* const listForm = new MyForm();
|
|
649
|
+
* //...
|
|
650
|
+
* expect(listForm.table());
|
|
651
|
+
*/
|
|
652
|
+
table() {
|
|
653
|
+
return new Table(this.getContainerElement, this.formName, this.driver);
|
|
654
|
+
}
|
|
655
|
+
/**
|
|
656
|
+
* Находит таблицу
|
|
657
|
+
* @example
|
|
658
|
+
* const listForm = new MyForm();
|
|
659
|
+
* //...
|
|
660
|
+
* expect(listForm.toolbarButton());
|
|
661
|
+
*/
|
|
662
|
+
toolbarButton(name) {
|
|
663
|
+
const toolbar = new TableToolbar(this.getContainerElement, this.formName, this.driver);
|
|
664
|
+
return toolbar.button(name);
|
|
298
665
|
}
|
|
299
666
|
};
|
|
300
667
|
|
|
@@ -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 };
|