d5-testing-library 1.0.4 → 1.1.0
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 +524 -86
- package/dist/d5-testing-library.d.ts +122 -19
- package/dist/d5-testing-library.legacy-esm.js +502 -76
- package/dist/d5-testing-library.mjs +502 -76
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as selenium_webdriver from 'selenium-webdriver';
|
|
2
|
-
import { WebDriver, Browser, By, Condition, WebElementPromise } from 'selenium-webdriver';
|
|
2
|
+
import { WebDriver, Browser, By, Condition, WebElement, WebElementPromise } from 'selenium-webdriver';
|
|
3
3
|
|
|
4
4
|
type DriverType = typeof Browser;
|
|
5
5
|
type BrowserList = DriverType[keyof DriverType];
|
|
@@ -16,7 +16,7 @@ type IConfig = {
|
|
|
16
16
|
declare function config(cfg?: IConfig): IConfig;
|
|
17
17
|
|
|
18
18
|
declare abstract class AbstractElement {
|
|
19
|
-
|
|
19
|
+
driver: WebDriver;
|
|
20
20
|
protected constructor(driver?: WebDriver);
|
|
21
21
|
}
|
|
22
22
|
|
|
@@ -35,6 +35,7 @@ declare class LoginPage extends AbstractPage {
|
|
|
35
35
|
usernameField: selenium_webdriver.By;
|
|
36
36
|
passwordField: selenium_webdriver.By;
|
|
37
37
|
loginButton: selenium_webdriver.By;
|
|
38
|
+
locate(): Promise<void>;
|
|
38
39
|
get path(): string;
|
|
39
40
|
enterUsername(username: string): Promise<void>;
|
|
40
41
|
enterPassword(password: string): Promise<void>;
|
|
@@ -64,8 +65,35 @@ declare const createDriver: (browser?: BrowserList) => Promise<WebDriver>;
|
|
|
64
65
|
|
|
65
66
|
declare const elementIsNotPresent: (locator: By) => Condition<boolean>;
|
|
66
67
|
|
|
68
|
+
interface WaitElementIsVisibleParams {
|
|
69
|
+
element: WebElement;
|
|
70
|
+
timeout?: number;
|
|
71
|
+
errorMessage?: string;
|
|
72
|
+
driver?: WebDriver;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Waits until a specified web element is visible within a given timeout.
|
|
76
|
+
*
|
|
77
|
+
* @param {WaitElementIsVisibleParams} params - The parameters for the wait function.
|
|
78
|
+
* @param {WebElement} params.element - The web element to wait for visibility.
|
|
79
|
+
* @param {number} [params.timeout] - The maximum time to wait for the element to be visible, in milliseconds. If not provided, the default timeout is used.
|
|
80
|
+
* @param {string} [params.errorMessage] - The error message to display if the wait times out. If not provided, a default error message is used.
|
|
81
|
+
* @param {WebDriver} [params.driver] - The web driver instance to use. If not provided, the default driver from the configuration is used.
|
|
82
|
+
* @returns {Promise<void>} A promise that resolves when the element becomes visible.
|
|
83
|
+
*/
|
|
84
|
+
declare function waitElementIsVisible({ element, timeout, errorMessage, driver }: WaitElementIsVisibleParams): Promise<void>;
|
|
85
|
+
|
|
67
86
|
declare function signIn(driver?: WebDriver): Promise<WebDriver>;
|
|
68
87
|
|
|
88
|
+
/**
|
|
89
|
+
* Clicks on a specified web element.
|
|
90
|
+
*
|
|
91
|
+
* @param {WebElement} webElement - The web element to click on.
|
|
92
|
+
* @param {WebDriver} [driver] - The web driver instance to use. If not provided, the default driver from the configuration is used.
|
|
93
|
+
* @returns {Promise<void>} A promise that resolves when the click action is complete.
|
|
94
|
+
*/
|
|
95
|
+
declare const click: (webElement: WebElement, driver?: WebDriver) => Promise<void>;
|
|
96
|
+
|
|
69
97
|
declare class SubsystemsPanel extends AbstractElement {
|
|
70
98
|
private panelBy;
|
|
71
99
|
private header;
|
|
@@ -101,44 +129,57 @@ declare abstract class AbstractForm extends AbstractPage {
|
|
|
101
129
|
}
|
|
102
130
|
|
|
103
131
|
declare abstract class AbstractElementWithParent extends AbstractElement {
|
|
104
|
-
|
|
132
|
+
getParentElement: () => Promise<WebElement>;
|
|
105
133
|
protected elementBy: By;
|
|
106
|
-
constructor(getParentElement: () =>
|
|
107
|
-
getElement(): Promise<
|
|
134
|
+
constructor(getParentElement: () => Promise<WebElement>, driver?: WebDriver);
|
|
135
|
+
getElement(): Promise<WebElement>;
|
|
136
|
+
getAttribute(attr: string): Promise<string>;
|
|
137
|
+
getClasses(): Promise<string>;
|
|
108
138
|
}
|
|
109
139
|
|
|
110
140
|
interface Editor {
|
|
111
141
|
setValue(value: any): Promise<void>;
|
|
112
142
|
getValue(): Promise<any>;
|
|
143
|
+
remove?(itemText: string): Promise<void>;
|
|
144
|
+
clear?(): Promise<void>;
|
|
113
145
|
}
|
|
114
146
|
|
|
115
147
|
declare class AbstractFormElement extends AbstractElementWithParent {
|
|
116
|
-
constructor(getParentElement: () =>
|
|
148
|
+
constructor(getParentElement: () => Promise<WebElement>, elementBy: By, driver?: WebDriver);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
interface ClearStrategy {
|
|
152
|
+
clear(editor: AbstractDXEditorWithInput): Promise<void>;
|
|
117
153
|
}
|
|
118
154
|
|
|
119
155
|
declare abstract class AbstractDXEditorWithInput extends AbstractFormElement implements Editor {
|
|
120
|
-
|
|
156
|
+
private clearStrategy;
|
|
157
|
+
protected setClearStrategy(strategy: ClearStrategy): void;
|
|
158
|
+
getInputElement(): Promise<selenium_webdriver.WebElement>;
|
|
121
159
|
protected getInputValue(): Promise<string>;
|
|
122
160
|
protected setInputValue(value: string): Promise<void>;
|
|
161
|
+
clear(): Promise<void>;
|
|
123
162
|
abstract setValue(value: any): Promise<void>;
|
|
124
163
|
abstract getValue(): Promise<any>;
|
|
125
164
|
}
|
|
126
165
|
|
|
127
166
|
declare class TextEditor extends AbstractDXEditorWithInput {
|
|
167
|
+
constructor(getParentElement: () => Promise<WebElement>, elementBy: By, driver: WebDriver);
|
|
128
168
|
getValue(): Promise<string>;
|
|
129
169
|
setValue(value: string): Promise<void>;
|
|
130
170
|
}
|
|
131
171
|
|
|
132
172
|
declare class NumberEditor extends AbstractDXEditorWithInput {
|
|
173
|
+
constructor(getParentElement: () => Promise<WebElement>, elementBy: By, driver: WebDriver);
|
|
133
174
|
getValue(): Promise<number | null>;
|
|
134
175
|
setValue(value: any): Promise<void>;
|
|
135
176
|
}
|
|
136
177
|
|
|
137
|
-
declare const editorFactory: (getParentElement: () =>
|
|
178
|
+
declare const editorFactory: (getParentElement: () => Promise<WebElement>, elementBy: By, driver?: WebDriver) => Promise<Editor>;
|
|
138
179
|
|
|
139
180
|
declare class FormField extends AbstractElementWithParent implements Editor {
|
|
140
181
|
editor: Editor;
|
|
141
|
-
constructor(getParentElement: () =>
|
|
182
|
+
constructor(getParentElement: () => Promise<WebElement>, formName: string, name: string, driver?: WebDriver);
|
|
142
183
|
private initEditor;
|
|
143
184
|
/**
|
|
144
185
|
* Возвращает значение в поле
|
|
@@ -154,6 +195,34 @@ declare class FormField extends AbstractElementWithParent implements Editor {
|
|
|
154
195
|
* await formEdit.field('TextFld').setValue('TestValue');
|
|
155
196
|
*/
|
|
156
197
|
setValue(value: any): Promise<void>;
|
|
198
|
+
/**
|
|
199
|
+
* Очищает значение в поле
|
|
200
|
+
* @example
|
|
201
|
+
* await formEdit.field('NumberFld').clear();
|
|
202
|
+
*/
|
|
203
|
+
clear(): Promise<void>;
|
|
204
|
+
/**
|
|
205
|
+
* Удаляет тег по переданному тексту
|
|
206
|
+
* @example
|
|
207
|
+
* await formEdit.field('TagBox').remove('test');
|
|
208
|
+
*/
|
|
209
|
+
remove(itemText: string): Promise<void>;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
interface Group {
|
|
213
|
+
isDisplayed(): Promise<boolean>;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
declare class FormGroup extends AbstractElementWithParent implements Group {
|
|
217
|
+
editor: Group;
|
|
218
|
+
constructor(getParentElement: () => Promise<WebElement>, formName: string, name: string, driver?: WebDriver);
|
|
219
|
+
private initEditor;
|
|
220
|
+
/**
|
|
221
|
+
* Возвращает булевое значение доступна ли группа
|
|
222
|
+
* @example
|
|
223
|
+
* expect(await tableList.group('MainSuperPanel').isDisplayed();
|
|
224
|
+
*/
|
|
225
|
+
isDisplayed(): Promise<boolean>;
|
|
157
226
|
}
|
|
158
227
|
|
|
159
228
|
declare abstract class FormEdit extends AbstractForm {
|
|
@@ -167,6 +236,22 @@ declare abstract class FormEdit extends AbstractForm {
|
|
|
167
236
|
* expect(await formEdit.field('Name').getValue()).toBe('test value');
|
|
168
237
|
*/
|
|
169
238
|
field(name: string): FormField;
|
|
239
|
+
/**
|
|
240
|
+
* Проверяет не отключена ли кнопка Сохранить
|
|
241
|
+
* @example
|
|
242
|
+
* const formEdit = new MyForm();
|
|
243
|
+
* //...
|
|
244
|
+
* await formEdit.isSaveButtonDisabled();
|
|
245
|
+
*/
|
|
246
|
+
isSaveButtonDisabled(): Promise<boolean>;
|
|
247
|
+
/**
|
|
248
|
+
* Находит группу формы редактирования по имени
|
|
249
|
+
* @example
|
|
250
|
+
* const formEdit = new MyForm();
|
|
251
|
+
* //...
|
|
252
|
+
* expect(await formEdit.group('Name');
|
|
253
|
+
*/
|
|
254
|
+
group(name: string): FormGroup;
|
|
170
255
|
/**
|
|
171
256
|
* Нажатие на кнопку Сохранить
|
|
172
257
|
* @example
|
|
@@ -178,6 +263,7 @@ declare abstract class FormEdit extends AbstractForm {
|
|
|
178
263
|
}
|
|
179
264
|
|
|
180
265
|
declare class TableToolbarButton extends AbstractElementWithParent {
|
|
266
|
+
private readonly name;
|
|
181
267
|
constructor(getParentElement: () => WebElementPromise, name: string, driver?: WebDriver);
|
|
182
268
|
click(): Promise<void>;
|
|
183
269
|
isDisabled(): Promise<boolean>;
|
|
@@ -185,14 +271,14 @@ declare class TableToolbarButton extends AbstractElementWithParent {
|
|
|
185
271
|
|
|
186
272
|
declare class Cell extends AbstractElementWithParent {
|
|
187
273
|
index: number;
|
|
188
|
-
constructor(
|
|
274
|
+
constructor(rowEl: WebElement, index: number, driver?: WebDriver);
|
|
189
275
|
getValue(): Promise<string>;
|
|
190
276
|
getIndex(): number;
|
|
191
277
|
}
|
|
192
278
|
|
|
193
279
|
declare class Column extends AbstractElementWithParent {
|
|
194
280
|
index: number;
|
|
195
|
-
constructor(getParentElement: () =>
|
|
281
|
+
constructor(getParentElement: () => Promise<WebElement>, index: number, driver?: WebDriver);
|
|
196
282
|
caption(): Promise<string>;
|
|
197
283
|
getIndex(): number;
|
|
198
284
|
}
|
|
@@ -200,8 +286,7 @@ declare class Column extends AbstractElementWithParent {
|
|
|
200
286
|
declare class Row extends AbstractElementWithParent {
|
|
201
287
|
index: number;
|
|
202
288
|
protected getColumnByCaption: (caption: string) => Promise<Column>;
|
|
203
|
-
constructor(getParentElement: () =>
|
|
204
|
-
protected getRowElement: () => WebElementPromise;
|
|
289
|
+
constructor(getParentElement: () => Promise<WebElement>, index: number, driver?: WebDriver, getColumnByCaption?: (caption: string) => Promise<Column>);
|
|
205
290
|
getCellByIndex(index: number): Promise<Cell>;
|
|
206
291
|
getCell(caption: string): Promise<Cell>;
|
|
207
292
|
select(): Promise<void>;
|
|
@@ -209,23 +294,33 @@ declare class Row extends AbstractElementWithParent {
|
|
|
209
294
|
getIndex(): number;
|
|
210
295
|
getCells(): Promise<Cell[]>;
|
|
211
296
|
private clickInlineButton;
|
|
297
|
+
private checkEditingMode;
|
|
212
298
|
edit(): Promise<void>;
|
|
213
299
|
save(): Promise<void>;
|
|
214
300
|
cancel(): Promise<void>;
|
|
215
301
|
}
|
|
216
302
|
|
|
217
303
|
declare class Table extends AbstractElementWithParent {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
protected
|
|
304
|
+
protected formName: string;
|
|
305
|
+
constructor(getParentElement: () => Promise<WebElement>, formName: string, driver?: WebDriver);
|
|
306
|
+
private getHeaderCssSelector;
|
|
307
|
+
protected getDataGrid(): Promise<WebElement>;
|
|
308
|
+
protected getTableElement: () => Promise<WebElement>;
|
|
222
309
|
getRowByIndex(index: number): Promise<Row>;
|
|
223
310
|
getColumnByIndex(index: number): Promise<Column>;
|
|
224
311
|
getColumnByCaption(caption: string): Promise<Column>;
|
|
225
312
|
selectRowByIndex(index: number): Promise<void>;
|
|
226
313
|
getRows(): Promise<Row[]>;
|
|
227
314
|
getColumns(): Promise<Column[]>;
|
|
228
|
-
element(): Promise<
|
|
315
|
+
element(): Promise<WebElement>;
|
|
316
|
+
/**
|
|
317
|
+
* Находит поле когда форма находится в состоянии редактирования
|
|
318
|
+
* @example
|
|
319
|
+
* const form = new MyForm();
|
|
320
|
+
* //...
|
|
321
|
+
* expect(await form.field('Name').getValue()).toBe('test value');
|
|
322
|
+
*/
|
|
323
|
+
field(name: string): FormField;
|
|
229
324
|
}
|
|
230
325
|
|
|
231
326
|
declare abstract class ListForm extends AbstractForm {
|
|
@@ -238,6 +333,14 @@ declare abstract class ListForm extends AbstractForm {
|
|
|
238
333
|
* expect(listForm.table());
|
|
239
334
|
*/
|
|
240
335
|
table(): Table;
|
|
336
|
+
/**
|
|
337
|
+
* Находит группу на лист форме по имени
|
|
338
|
+
* @example
|
|
339
|
+
* const formEdit = new MyForm();
|
|
340
|
+
* //...
|
|
341
|
+
* expect(await formEdit.group('Name');
|
|
342
|
+
*/
|
|
343
|
+
group(name: string): FormGroup;
|
|
241
344
|
/**
|
|
242
345
|
* Находит таблицу
|
|
243
346
|
* @example
|
|
@@ -248,4 +351,4 @@ declare abstract class ListForm extends AbstractForm {
|
|
|
248
351
|
toolbarButton(name: string): Promise<TableToolbarButton>;
|
|
249
352
|
}
|
|
250
353
|
|
|
251
|
-
export { AbstractPage, Editor, FormEdit, FormField, ListForm, LoginPage, NumberEditor, SubsystemsPanel, TextEditor, byTestId, config, createDriver, editorFactory, elementIsNotPresent, signIn };
|
|
354
|
+
export { AbstractPage, Editor, FormEdit, FormField, ListForm, LoginPage, NumberEditor, SubsystemsPanel, TextEditor, byTestId, click, config, createDriver, editorFactory, elementIsNotPresent, signIn, waitElementIsVisible };
|