@anddone/coretestautomation 1.0.1
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/.github/workflows/npm-release.yml +102 -0
- package/dist/api/base.api.d.ts +32 -0
- package/dist/api/base.api.d.ts.map +1 -0
- package/dist/api/base.api.js +7 -0
- package/dist/api/base.api.js.map +1 -0
- package/dist/api/headers.d.ts +6 -0
- package/dist/api/headers.d.ts.map +1 -0
- package/dist/api/headers.js +23 -0
- package/dist/api/headers.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/dist/pages/basepage.d.ts +6 -0
- package/dist/pages/basepage.d.ts.map +1 -0
- package/dist/pages/basepage.js +10 -0
- package/dist/pages/basepage.js.map +1 -0
- package/dist/testData/api.data.json +6 -0
- package/dist/utils/apiUtils.d.ts +123 -0
- package/dist/utils/apiUtils.d.ts.map +1 -0
- package/dist/utils/apiUtils.js +264 -0
- package/dist/utils/apiUtils.js.map +1 -0
- package/dist/utils/assertionUtils.d.ts +223 -0
- package/dist/utils/assertionUtils.d.ts.map +1 -0
- package/dist/utils/assertionUtils.js +400 -0
- package/dist/utils/assertionUtils.js.map +1 -0
- package/dist/utils/commonUtils.d.ts +590 -0
- package/dist/utils/commonUtils.d.ts.map +1 -0
- package/dist/utils/commonUtils.js +1292 -0
- package/dist/utils/commonUtils.js.map +1 -0
- package/dist/utils/fakerStaticData.d.ts +16 -0
- package/dist/utils/fakerStaticData.d.ts.map +1 -0
- package/dist/utils/fakerStaticData.js +88 -0
- package/dist/utils/fakerStaticData.js.map +1 -0
- package/dist/utils/fileCommonUtils.d.ts +22 -0
- package/dist/utils/fileCommonUtils.d.ts.map +1 -0
- package/dist/utils/fileCommonUtils.js +243 -0
- package/dist/utils/fileCommonUtils.js.map +1 -0
- package/dist/utils/generationUtils.d.ts +424 -0
- package/dist/utils/generationUtils.d.ts.map +1 -0
- package/dist/utils/generationUtils.js +869 -0
- package/dist/utils/generationUtils.js.map +1 -0
- package/dist/utils/pageUtils.d.ts +90 -0
- package/dist/utils/pageUtils.d.ts.map +1 -0
- package/dist/utils/pageUtils.js +214 -0
- package/dist/utils/pageUtils.js.map +1 -0
- package/dist/utils/tableUtils.d.ts +304 -0
- package/dist/utils/tableUtils.d.ts.map +1 -0
- package/dist/utils/tableUtils.js +555 -0
- package/dist/utils/tableUtils.js.map +1 -0
- package/dist/utils/validationUtils.d.ts +80 -0
- package/dist/utils/validationUtils.d.ts.map +1 -0
- package/dist/utils/validationUtils.js +172 -0
- package/dist/utils/validationUtils.js.map +1 -0
- package/package.json +23 -0
- package/playwright.config.ts +79 -0
- package/src/api/base.api.ts +39 -0
- package/src/api/headers.ts +17 -0
- package/src/index.ts +12 -0
- package/src/pages/basepage.ts +11 -0
- package/src/testData/api.data.json +6 -0
- package/src/types/pdf-parse.d.ts +6 -0
- package/src/utils/apiUtils.ts +307 -0
- package/src/utils/assertionUtils.ts +455 -0
- package/src/utils/commonUtils.ts +1544 -0
- package/src/utils/fakerStaticData.ts +91 -0
- package/src/utils/fileCommonUtils.ts +239 -0
- package/src/utils/generationUtils.ts +929 -0
- package/src/utils/pageUtils.ts +224 -0
- package/src/utils/tableUtils.ts +715 -0
- package/src/utils/validationUtils.ts +179 -0
- package/tsconfig.json +19 -0
|
@@ -0,0 +1,555 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TableUtils = void 0;
|
|
4
|
+
const commonUtils_1 = require("./commonUtils");
|
|
5
|
+
class TableUtils extends commonUtils_1.CommonUtils {
|
|
6
|
+
/**
|
|
7
|
+
* Resolves options by applying defaults.
|
|
8
|
+
*
|
|
9
|
+
* @param options - User-provided options
|
|
10
|
+
* @param defaults - Default values for the options
|
|
11
|
+
* @returns Complete options object with defaults applied
|
|
12
|
+
*/
|
|
13
|
+
static resolveTableOptions(options = {}, defaults) {
|
|
14
|
+
return { ...defaults, ...options };
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Gets the text values of table headers.
|
|
18
|
+
*
|
|
19
|
+
* @param table - Locator of the table element
|
|
20
|
+
* @param options - Optional configuration for header locators and timeout
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* const headers = await CommonUtils.getTableHeaders(table);
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* const headers = await CommonUtils.getTableHeaders(table, {
|
|
27
|
+
* headerExpression: 'thead tr th',
|
|
28
|
+
* timeout: 5000
|
|
29
|
+
* });
|
|
30
|
+
*
|
|
31
|
+
* @returns Array of trimmed header texts, or empty array if not found
|
|
32
|
+
*/
|
|
33
|
+
static async getTableHeaders(table, options = {}) {
|
|
34
|
+
const { headerExpression = 'tr th', timeout = 15000 } = this.resolveTableOptions(options, {});
|
|
35
|
+
try {
|
|
36
|
+
const headers = table.locator(headerExpression);
|
|
37
|
+
await this.waitForVisible(headers.first(), { timeout });
|
|
38
|
+
const count = await headers.count();
|
|
39
|
+
const results = [];
|
|
40
|
+
for (let i = 0; i < count; i++) {
|
|
41
|
+
results.push((await headers.nth(i).innerText()).trim());
|
|
42
|
+
}
|
|
43
|
+
return results;
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
console.warn('⚠ Unable to get table headers:', error.message);
|
|
47
|
+
return [];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Returns the zero-based index of a column based on the column header name.
|
|
52
|
+
*
|
|
53
|
+
* If the column header is not found or an error occurs, `-1` is returned.
|
|
54
|
+
* @param table - Locator pointing to the table element
|
|
55
|
+
* @param columnName - Visible header text to search for
|
|
56
|
+
* @param options - Optional configuration for header locators and timeout
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* const headers = await CommonUtils.getColumnIndex(table,'columnName');
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* const headers = await CommonUtils.getColumnIndex(table,
|
|
63
|
+
* 'columnName',{ headerExpression: 'thead tr th',
|
|
64
|
+
* timeout: 5000
|
|
65
|
+
* });
|
|
66
|
+
* @returns Promise<number> - Zero-based column index if found, otherwise -1
|
|
67
|
+
*/
|
|
68
|
+
static async getColumnIndex(table, columnName, options = {}) {
|
|
69
|
+
const { headerExpression = "tr th" } = this.resolveTableOptions(options, {});
|
|
70
|
+
try {
|
|
71
|
+
const headers = table.locator(headerExpression);
|
|
72
|
+
await this.waitForVisible(headers.first());
|
|
73
|
+
const count = await headers.count();
|
|
74
|
+
for (let i = 0; i < count; i++) {
|
|
75
|
+
const header = headers.nth(i);
|
|
76
|
+
const headerText = (await header.innerText()).trim();
|
|
77
|
+
if (headerText === columnName.trim()) {
|
|
78
|
+
return i;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return -1;
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
return -1;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Gets the text value of a specific cell by row and column index.
|
|
89
|
+
*
|
|
90
|
+
* @param table - Locator representing the table
|
|
91
|
+
* @param rowIndex - 1 - based index of the row
|
|
92
|
+
* @param columnIndex - 0 -based index of the column
|
|
93
|
+
* @param options - Optional table settings
|
|
94
|
+
* @param options.rowLocator - Locator for table rows (default: '//tr[contains(@class,"row")]')
|
|
95
|
+
* @param options.cellLocator - Locator for table cells (default: 'td')
|
|
96
|
+
* @param options.timeout - Maximum wait time for elements (default: 15000)
|
|
97
|
+
*
|
|
98
|
+
* @returns Cell value as string or empty string if not found
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* const value = await CommonUtils.getCellValueByIndex(table, 2, 1);
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* const value = await CommonUtils.getCellValueByIndex(table, 2, 1, {
|
|
105
|
+
* rowLocator: '//tbody/tr',
|
|
106
|
+
* cellLocator: 'td',
|
|
107
|
+
* timeout: 8000
|
|
108
|
+
* });
|
|
109
|
+
*/
|
|
110
|
+
static async getCellValueByIndex(table, rowIndex, columnIndex, options = {}) {
|
|
111
|
+
const { rowLocator = '//tr[contains(@class,"row")]', cellLocator = 'td', timeout = 15000 } = this.resolveTableOptions(options, {});
|
|
112
|
+
try {
|
|
113
|
+
if (rowIndex < 1) {
|
|
114
|
+
console.error(`Row index must be >= 1. Received: ${rowIndex}`);
|
|
115
|
+
return '';
|
|
116
|
+
}
|
|
117
|
+
if (columnIndex < 0) {
|
|
118
|
+
console.error(`Column index must be >= 0. Received: ${columnIndex}`);
|
|
119
|
+
return '';
|
|
120
|
+
}
|
|
121
|
+
const rows = table.locator(rowLocator);
|
|
122
|
+
await this.waitForVisible(rows.first(), { timeout });
|
|
123
|
+
const rowCount = await rows.count();
|
|
124
|
+
if (rowIndex > rowCount) {
|
|
125
|
+
console.error(`Row index ${rowIndex} exceeds total rows ${rowCount}`);
|
|
126
|
+
return '';
|
|
127
|
+
}
|
|
128
|
+
const row = rows.nth(rowIndex - 1);
|
|
129
|
+
const cells = row.locator(cellLocator);
|
|
130
|
+
const cellCount = await cells.count();
|
|
131
|
+
if (columnIndex >= cellCount) {
|
|
132
|
+
console.error(`Column index ${columnIndex} exceeds total columns ${cellCount}`);
|
|
133
|
+
return '';
|
|
134
|
+
}
|
|
135
|
+
const cell = cells.nth(columnIndex);
|
|
136
|
+
const value = (await cell.innerText()).trim();
|
|
137
|
+
return value;
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
console.error(`⚠ Failed to get cell value at row ${rowIndex}, column ${columnIndex}: ${error.message}`);
|
|
141
|
+
return '';
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Retrieves all cell values from a specific column of a table using a zero-based column index.
|
|
146
|
+
*
|
|
147
|
+
* If the column index is invalid (< 0), or if an error occurs,
|
|
148
|
+
* an empty array is returned.
|
|
149
|
+
*
|
|
150
|
+
* @param table - Locator pointing to the table element
|
|
151
|
+
* @param columnIndex - Zero-based index of the column
|
|
152
|
+
* @param options - Optional table settings
|
|
153
|
+
* @param options.rowLocator - Selector for table rows (default: '//tr[contains(@class,"row")]')
|
|
154
|
+
* @param options.cellLocator - Selector for cells inside a row (default: 'td')
|
|
155
|
+
* @param options.timeout - Maximum wait time for the elements (default: 15000)
|
|
156
|
+
*
|
|
157
|
+
* @returns Promise<string[]> - Array of cell values from the specified column
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* const values = await CommonUtils.getColumnValuesByIndex(table, 1);
|
|
161
|
+
*
|
|
162
|
+
* @example
|
|
163
|
+
* const values = await CommonUtils.getColumnValuesByIndex(table, 2, {
|
|
164
|
+
* rowLocator: '//tbody/tr',
|
|
165
|
+
* cellLocator: 'td',
|
|
166
|
+
* timeout: 8000
|
|
167
|
+
* });
|
|
168
|
+
*/
|
|
169
|
+
static async getColumnValuesByIndex(table, columnIndex, options = {}) {
|
|
170
|
+
const { rowLocator = '//tr[contains(@class,"row")]', cellLocator = 'td', timeout = 15000 } = this.resolveTableOptions(options, {});
|
|
171
|
+
const values = [];
|
|
172
|
+
if (columnIndex < 0)
|
|
173
|
+
return values;
|
|
174
|
+
try {
|
|
175
|
+
const rows = table.locator(rowLocator);
|
|
176
|
+
await this.waitForVisible(rows.first(), { timeout });
|
|
177
|
+
const rowCount = await rows.count();
|
|
178
|
+
for (let i = 0; i < rowCount; i++) {
|
|
179
|
+
const row = rows.nth(i);
|
|
180
|
+
const cells = row.locator(cellLocator);
|
|
181
|
+
const cellCount = await cells.count();
|
|
182
|
+
if (cellCount <= columnIndex)
|
|
183
|
+
continue;
|
|
184
|
+
const cell = cells.nth(columnIndex);
|
|
185
|
+
const value = (await cell.innerText()).trim();
|
|
186
|
+
values.push(value);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
catch (error) {
|
|
190
|
+
console.warn(`⚠ Failed to get column values for column index ${columnIndex}: ${error.message}`);
|
|
191
|
+
return [];
|
|
192
|
+
}
|
|
193
|
+
return values;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Returns all cell values from a table for the given column header.
|
|
197
|
+
*
|
|
198
|
+
* If the header is not found, an empty array is returned.
|
|
199
|
+
*
|
|
200
|
+
* @param table - Locator for the table element
|
|
201
|
+
* @param columnName - Exact column header text to search
|
|
202
|
+
* @param options - Optional table settings
|
|
203
|
+
* @param options.headerExpression - Locator for headers (default: 'tr th')
|
|
204
|
+
* @param options.rowLocator - Locator for rows (default: '//tr[contains(@class,"row")]')
|
|
205
|
+
* @param options.cellLocator - Locator for cells (default: 'td')
|
|
206
|
+
* @param options.timeout - Maximum wait time for elements (default: 15000)
|
|
207
|
+
*
|
|
208
|
+
* @returns Promise<string[]> - Array of cell values under the specified column
|
|
209
|
+
*
|
|
210
|
+
* @example
|
|
211
|
+
* const values = await CommonUtils.getColumnValuesByHeader(table, 'Name');
|
|
212
|
+
*
|
|
213
|
+
* @example
|
|
214
|
+
* const values = await CommonUtils.getColumnValuesByHeader(table, 'Name', {
|
|
215
|
+
* headerExpression: 'thead tr th',
|
|
216
|
+
* rowLocator: '//tbody/tr',
|
|
217
|
+
* cellLocator: 'td',
|
|
218
|
+
* timeout: 8000
|
|
219
|
+
* });
|
|
220
|
+
*/
|
|
221
|
+
static async getColumnValuesByHeader(table, columnName, options = {}) {
|
|
222
|
+
const { headerExpression = 'tr th', rowLocator = '//tr[contains(@class,"row")]', cellLocator = 'td', timeout = 15000 } = this.resolveTableOptions(options, {});
|
|
223
|
+
try {
|
|
224
|
+
// Get the column index for the header
|
|
225
|
+
const columnIndex = await this.getColumnIndex(table, columnName, { headerExpression, timeout });
|
|
226
|
+
if (columnIndex === -1) {
|
|
227
|
+
console.error(`⚠ Column header not found: "${columnName}"`);
|
|
228
|
+
return [];
|
|
229
|
+
}
|
|
230
|
+
// Return all cell values from that column
|
|
231
|
+
return await this.getColumnValuesByIndex(table, columnIndex, { rowLocator, cellLocator, timeout });
|
|
232
|
+
}
|
|
233
|
+
catch (error) {
|
|
234
|
+
console.error(`⚠ Failed to get column values for header "${columnName}": ${error.message}`);
|
|
235
|
+
return [];
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Clicks a table row based on its row index (1-based).
|
|
240
|
+
*
|
|
241
|
+
* The row index is **1-based** for ease of use:
|
|
242
|
+
* - 1 → first row
|
|
243
|
+
* - 2 → second row
|
|
244
|
+
*
|
|
245
|
+
* If the index is invalid or out of range, an error is logged
|
|
246
|
+
* and the action is safely skipped.
|
|
247
|
+
*
|
|
248
|
+
* @param page - Playwright Page object
|
|
249
|
+
* @param table - Locator pointing to the table element
|
|
250
|
+
* @param rowIndex - Row index to click on (1-based)
|
|
251
|
+
* @param options - Optional table settings
|
|
252
|
+
* @param options.rowLocator - Selector used to locate rows (default: '//tr[contains(@class,"row")]')
|
|
253
|
+
* @param options.timeout - Maximum wait time for elements (default: 15000)
|
|
254
|
+
*
|
|
255
|
+
* @example
|
|
256
|
+
* await CommonUtils.clickOnTableRowByIndex(page, table, 1);
|
|
257
|
+
*
|
|
258
|
+
* @example
|
|
259
|
+
* await CommonUtils.clickOnTableRowByIndex(page, table, 2, {
|
|
260
|
+
* rowLocator: '//tbody/tr',
|
|
261
|
+
* timeout: 8000
|
|
262
|
+
* });
|
|
263
|
+
*/
|
|
264
|
+
static async clickOnTableRowByIndex(table, rowIndex, options = {}) {
|
|
265
|
+
const { rowLocator = '//tr[contains(@class,"row")]', timeout = 15000 } = this.resolveTableOptions(options, {});
|
|
266
|
+
try {
|
|
267
|
+
if (rowIndex < 1) {
|
|
268
|
+
console.error(`⚠ Row index must be >= 1. Received: ${rowIndex}`);
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
const rows = table.locator(rowLocator);
|
|
272
|
+
await this.waitForVisible(rows.first(), { timeout });
|
|
273
|
+
const rowCount = await rows.count();
|
|
274
|
+
if (rowIndex > rowCount) {
|
|
275
|
+
console.error(`⚠ Row index ${rowIndex} is out of range. Total rows available: ${rowCount}`);
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
const row = rows.nth(rowIndex - 1);
|
|
279
|
+
await this.click(row, { timeout });
|
|
280
|
+
}
|
|
281
|
+
catch (error) {
|
|
282
|
+
console.error(`⚠ Failed to click table row at index ${rowIndex}: ${error.message}`);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Clicks a table column header based on the given column name.
|
|
287
|
+
*
|
|
288
|
+
* @param table - Locator pointing to the table element
|
|
289
|
+
* @param columnName - Visible column header name to click
|
|
290
|
+
* @param options - Optional table settings
|
|
291
|
+
* @param options.headerExpression - Locator expression for table headers
|
|
292
|
+
* (default: 'tr th button')
|
|
293
|
+
* @param options.timeout - Maximum wait time for elements (default: 15000)
|
|
294
|
+
*
|
|
295
|
+
* @returns Locator of the clicked header or null if not found
|
|
296
|
+
*
|
|
297
|
+
* @example
|
|
298
|
+
* await CommonUtils.clickOnTableColumnHeader(table, 'Name');
|
|
299
|
+
*
|
|
300
|
+
* @example
|
|
301
|
+
* await CommonUtils.clickOnTableColumnHeader(table, 'Amount', {
|
|
302
|
+
* headerExpression: 'thead tr th',
|
|
303
|
+
* timeout: 8000
|
|
304
|
+
* });
|
|
305
|
+
*/
|
|
306
|
+
static async clickOnTableColumnHeader(table, columnName, options = {}) {
|
|
307
|
+
const { headerExpression = 'tr th button', timeout = 15000 } = this.resolveTableOptions(options, {});
|
|
308
|
+
try {
|
|
309
|
+
if (!columnName || columnName.trim() === '') {
|
|
310
|
+
console.error('⚠ Column name must be a non-empty string');
|
|
311
|
+
return null;
|
|
312
|
+
}
|
|
313
|
+
const headers = table.locator(headerExpression);
|
|
314
|
+
await this.waitForVisible(headers.first(), { timeout });
|
|
315
|
+
const count = await headers.count();
|
|
316
|
+
for (let i = 0; i < count; i++) {
|
|
317
|
+
const header = headers.nth(i);
|
|
318
|
+
const text = (await header.innerText())
|
|
319
|
+
.replace(/\s+/g, ' ')
|
|
320
|
+
.replace(/\u00A0/g, ' ')
|
|
321
|
+
.trim();
|
|
322
|
+
if (text.toLowerCase().includes(columnName.toLowerCase())) {
|
|
323
|
+
await header.scrollIntoViewIfNeeded();
|
|
324
|
+
await this.click(header, { timeout });
|
|
325
|
+
return header;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
console.error(`⚠ Column header "${columnName}" not found`);
|
|
329
|
+
return null;
|
|
330
|
+
}
|
|
331
|
+
catch (error) {
|
|
332
|
+
console.error(`⚠ Failed to click column header "${columnName}": ${error.message}`);
|
|
333
|
+
return null;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Clicks a specific table cell using row and column indexes.
|
|
338
|
+
*
|
|
339
|
+
* Indexes are **1-based**:
|
|
340
|
+
* - rowIndex: 1 → first row
|
|
341
|
+
* - columnIndex: 1 → first column
|
|
342
|
+
*
|
|
343
|
+
* @param table - Locator for the table element
|
|
344
|
+
* @param rowIndex - 1-based index of the row to click
|
|
345
|
+
* @param columnIndex - 1-based index of the column to click
|
|
346
|
+
* @param options - Optional table settings
|
|
347
|
+
* @param options.rowLocator - Locator for table rows
|
|
348
|
+
* (default: '//tr[contains(@class,"row")]')
|
|
349
|
+
* @param options.cellLocator - Locator for table cells (default: 'td')
|
|
350
|
+
* @param options.timeout - Maximum wait time (default: 15000)
|
|
351
|
+
*
|
|
352
|
+
* @example
|
|
353
|
+
* await CommonUtils.clickTableCell(table, 2, 3);
|
|
354
|
+
*
|
|
355
|
+
* @example
|
|
356
|
+
* await CommonUtils.clickTableCell(table, 1, 1, {
|
|
357
|
+
* rowLocator: '//tbody/tr',
|
|
358
|
+
* cellLocator: 'td',
|
|
359
|
+
* timeout: 8000
|
|
360
|
+
* });
|
|
361
|
+
*/
|
|
362
|
+
static async clickTableCell(table, rowIndex, columnIndex, options = {}) {
|
|
363
|
+
const { rowLocator = '//tr[contains(@class,"row")]', cellLocator = 'td', timeout = 15000 } = this.resolveTableOptions(options, {});
|
|
364
|
+
try {
|
|
365
|
+
if (rowIndex < 1 || columnIndex < 1) {
|
|
366
|
+
console.error(`⚠ Row and column indexes must be >= 1`);
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
const rows = table.locator(rowLocator);
|
|
370
|
+
await this.waitForVisible(rows.first(), { timeout });
|
|
371
|
+
const row = rows.nth(rowIndex - 1);
|
|
372
|
+
const cell = row.locator(cellLocator).nth(columnIndex - 1);
|
|
373
|
+
await cell.scrollIntoViewIfNeeded();
|
|
374
|
+
await this.click(cell, { timeout });
|
|
375
|
+
}
|
|
376
|
+
catch (err) {
|
|
377
|
+
console.error(`⚠ clickTableCell failed at row ${rowIndex}, column ${columnIndex}: ${err.message}`);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* Clicks the ellipsis (actions) button in the specified table row.
|
|
382
|
+
*
|
|
383
|
+
* Row index is **1-based**:
|
|
384
|
+
* - 1 → first row
|
|
385
|
+
* - 2 → second row
|
|
386
|
+
*
|
|
387
|
+
* If the row index is invalid, ellipsis is not found,
|
|
388
|
+
* or any error occurs, the action is skipped safely.
|
|
389
|
+
*
|
|
390
|
+
* @param table - Table locator
|
|
391
|
+
* @param rowIndex - 1-based row index
|
|
392
|
+
* @param options - Optional table settings
|
|
393
|
+
* @param options.ellipsisLocator - Selector for the ellipsis button
|
|
394
|
+
* (default: 'button#detailsDropdown')
|
|
395
|
+
* @param options.rowLocator - Selector for table rows
|
|
396
|
+
* (default: '//tr[contains(@class,"row")]')
|
|
397
|
+
* @param options.timeout - Maximum wait time (default: 15000)
|
|
398
|
+
*
|
|
399
|
+
* @returns true if clicked successfully, otherwise false
|
|
400
|
+
*
|
|
401
|
+
* @example
|
|
402
|
+
* const clicked = await CommonUtils.clickEllipsisByRowIndex(table, 1);
|
|
403
|
+
*
|
|
404
|
+
* @example
|
|
405
|
+
* const clicked = await CommonUtils.clickEllipsisByRowIndex(table, 2, {
|
|
406
|
+
* ellipsisLocator: 'button.more-actions',
|
|
407
|
+
* rowLocator: '//tbody/tr',
|
|
408
|
+
* timeout: 8000
|
|
409
|
+
* });
|
|
410
|
+
*/
|
|
411
|
+
static async clickEllipsisByRowIndex(table, rowIndex, options = {}) {
|
|
412
|
+
const { ellipsisLocator = 'button#detailsDropdown', rowLocator = '//tr[contains(@class,"row")]', timeout = 15000 } = this.resolveTableOptions(options, {});
|
|
413
|
+
try {
|
|
414
|
+
if (rowIndex < 1) {
|
|
415
|
+
console.error('⚠ Row index must be >= 1');
|
|
416
|
+
return false;
|
|
417
|
+
}
|
|
418
|
+
const rows = table.locator(rowLocator);
|
|
419
|
+
await this.waitForVisible(rows.first(), { timeout });
|
|
420
|
+
const row = rows.nth(rowIndex - 1);
|
|
421
|
+
await row.scrollIntoViewIfNeeded();
|
|
422
|
+
const ellipsis = row.locator(ellipsisLocator);
|
|
423
|
+
if (await ellipsis.count() === 0) {
|
|
424
|
+
console.warn('⚠ Ellipsis button not found in the specified row');
|
|
425
|
+
return false;
|
|
426
|
+
}
|
|
427
|
+
await this.click(ellipsis.first(), { timeout });
|
|
428
|
+
return true;
|
|
429
|
+
}
|
|
430
|
+
catch (error) {
|
|
431
|
+
console.error(`⚠ Failed to click ellipsis at row ${rowIndex}: ${error.message}`);
|
|
432
|
+
return false;
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* Clicks the ellipsis for a given table row and selects
|
|
437
|
+
* a filter/action option from the displayed options list.
|
|
438
|
+
*
|
|
439
|
+
* @param table - Locator representing the table element
|
|
440
|
+
* @param rowIndex - 1-based index of the row
|
|
441
|
+
* @param optionsList - Locator representing the list of filter options
|
|
442
|
+
* @param optionText - Visible text of the option to select
|
|
443
|
+
* @param options - Optional table/action configuration
|
|
444
|
+
*/
|
|
445
|
+
static async clickEllipsisAndSelectFilterOption(table, rowIndex, optionsList, optionText, options = {}) {
|
|
446
|
+
const { timeout = 15000 } = this.resolveTableOptions(options, {});
|
|
447
|
+
const ellipsisClicked = await this.clickEllipsisByRowIndex(table, rowIndex, options);
|
|
448
|
+
if (!ellipsisClicked) {
|
|
449
|
+
console.warn('⚠ Unable to click ellipsis');
|
|
450
|
+
return false;
|
|
451
|
+
}
|
|
452
|
+
return await this.clickOnFilterOptionFromList(optionsList, optionText, { timeout });
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* Clicks the Apply button inside a visible dropdown container.
|
|
456
|
+
*
|
|
457
|
+
* @param filterPopupBox - Locator representing the dropdown container
|
|
458
|
+
* @param options - TableOptions options (timeout, description, applyButtonLocator -
|
|
459
|
+
* default- a.filter-button.apply)
|
|
460
|
+
* @returns boolean - true if clicked successfully, otherwise false
|
|
461
|
+
*/
|
|
462
|
+
static async clickApplyButton(filterPopupBox, options = {}) {
|
|
463
|
+
const { timeout = 15000, description = 'Apply button', applyButtonLocator = 'a.filter-button.apply' } = this.resolveTableOptions(options, { timeout: 15000 });
|
|
464
|
+
try {
|
|
465
|
+
const applyButton = filterPopupBox.locator(applyButtonLocator);
|
|
466
|
+
await this.click(applyButton, { timeout, description });
|
|
467
|
+
return true;
|
|
468
|
+
}
|
|
469
|
+
catch (error) {
|
|
470
|
+
console.error(`⚠ Failed to click ${description}: ${error.message}`);
|
|
471
|
+
return false;
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* Clicks the "Clear" button inside a dropdown container.
|
|
476
|
+
*
|
|
477
|
+
* @param filterPopupBox - Locator representing the dropdown container
|
|
478
|
+
* @param options - TableOptions options (timeout, description, clearButtonLocator)
|
|
479
|
+
* @returns boolean - true if clicked successfully, otherwise false
|
|
480
|
+
*/
|
|
481
|
+
static async clickClearButton(filterPopupBox, options = {}) {
|
|
482
|
+
const { timeout = 15000, description = 'Clear button', clearButtonLocator = 'a.filter-button.clear' } = this.resolveTableOptions(options, { timeout: 15000 });
|
|
483
|
+
try {
|
|
484
|
+
const clearButton = filterPopupBox.locator(clearButtonLocator);
|
|
485
|
+
await this.waitForVisible(clearButton);
|
|
486
|
+
await this.click(clearButton, { timeout, description });
|
|
487
|
+
return true;
|
|
488
|
+
}
|
|
489
|
+
catch (error) {
|
|
490
|
+
console.error(`⚠ Failed to click ${description}: ${error.message}`);
|
|
491
|
+
return false;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* Enters a "From" date into the date filter input inside a dropdown.
|
|
496
|
+
*
|
|
497
|
+
* @param filterPopupBox - Locator for the filter dropdown/popup
|
|
498
|
+
* @param fromDate - Date string to enter into the input
|
|
499
|
+
* @param options - Optional settings from TableOptions:
|
|
500
|
+
* - dateInputLocator: custom locator for the "From" date input (defualt - input#inputFromDate)
|
|
501
|
+
*/
|
|
502
|
+
static async enterFromDate(filterPopupBox, fromDate, options = {}) {
|
|
503
|
+
const { timeout = 15000, description = 'From Date Input', dateInputLocator = 'input#inputFromDate' } = this.resolveTableOptions(options, { timeout: 15000 });
|
|
504
|
+
try {
|
|
505
|
+
const fromInput = filterPopupBox.locator(dateInputLocator).first();
|
|
506
|
+
await this.waitForVisible(fromInput, { timeout });
|
|
507
|
+
await this.fill(fromInput, fromDate, { timeout, description });
|
|
508
|
+
}
|
|
509
|
+
catch (error) {
|
|
510
|
+
console.error(`⚠ Failed to enter From Date "${fromDate}": ${error.message}`);
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* Enters a "To" date into the date filter input inside a dropdown.
|
|
515
|
+
* *
|
|
516
|
+
* @param filterPopupBox - Locator for the filter dropdown/popup
|
|
517
|
+
* @param toDate - Date string to enter into the input
|
|
518
|
+
* @param options - Optional settings from TableOptions:
|
|
519
|
+
* - dateInputLocator: custom locator for the "To" date input (defualt - input#inputToDate)
|
|
520
|
+
*/
|
|
521
|
+
static async enterToDate(filterPopupBox, toDate, options = {}) {
|
|
522
|
+
const { timeout = 15000, description = 'To Date Input', dateInputLocator = 'input#inputToDate' } = this.resolveTableOptions(options, { timeout: 15000 });
|
|
523
|
+
try {
|
|
524
|
+
const toInput = filterPopupBox.locator(dateInputLocator).first();
|
|
525
|
+
await this.waitForVisible(toInput, { timeout });
|
|
526
|
+
await this.fill(toInput, toDate, { timeout, description });
|
|
527
|
+
}
|
|
528
|
+
catch (error) {
|
|
529
|
+
console.error(`⚠ Failed to enter To Date "${toDate}": ${error.message}`);
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
/**
|
|
533
|
+
* Enters a value into an input field inside a filter/dropdown container.
|
|
534
|
+
*
|
|
535
|
+
* @param filterPopupBox - Locator for the dropdown/filter container
|
|
536
|
+
* @param value - Text value to enter
|
|
537
|
+
* @param options - Optional TableOptions:
|
|
538
|
+
* - inputLocator: selector for the input field (default: 'input')
|
|
539
|
+
* - timeout: max wait time (default: 15000)
|
|
540
|
+
* - description: description used in logs (default: 'Filter Input')
|
|
541
|
+
*/
|
|
542
|
+
static async enterInputValue(filterPopupBox, value, options = {}) {
|
|
543
|
+
const { inputLocator = 'input', timeout = 15000, description = 'Filter Input' } = this.resolveTableOptions(options, { timeout: 15000 });
|
|
544
|
+
try {
|
|
545
|
+
const input = filterPopupBox.locator(inputLocator).first();
|
|
546
|
+
await this.waitForVisible(input, { timeout });
|
|
547
|
+
await this.fill(input, value, { timeout, description });
|
|
548
|
+
}
|
|
549
|
+
catch (error) {
|
|
550
|
+
console.error(`⚠ Failed to enter value "${value}" in ${description}: ${error.message}`);
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
exports.TableUtils = TableUtils;
|
|
555
|
+
//# sourceMappingURL=tableUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tableUtils.js","sourceRoot":"","sources":["../../src/utils/tableUtils.ts"],"names":[],"mappings":";;;AACA,+CAA4C;AAe5C,MAAa,UAAW,SAAQ,yBAAW;IAEvC;;;;;;OAMG;IACK,MAAM,CAAC,mBAAmB,CAAmB,UAAsB,EAA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,CAAC;QAC5D,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,OAAO,CAAC,KAAK,CAAC,4BAA4B,KAAK,QAAQ,WAAW,KAAM,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;QACvG,CAAC;IACL,CAAC;CACJ;AA1rBD,gCA0rBC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
export declare class ValidationUtils {
|
|
2
|
+
/**
|
|
3
|
+
* Checks whether a Date object is valid.
|
|
4
|
+
*
|
|
5
|
+
* @param date Date object
|
|
6
|
+
* @returns true if valid Date, false otherwise
|
|
7
|
+
*/
|
|
8
|
+
static isValidDate(date: Date): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Checks whether two dates fall on the same calendar day.
|
|
11
|
+
*
|
|
12
|
+
* @param date1 First date
|
|
13
|
+
* @param date2 Second date
|
|
14
|
+
* @returns True if date1 is before date2
|
|
15
|
+
*/
|
|
16
|
+
static isBefore(date1: Date, date2: Date): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Checks whether two dates fall on the same calendar day.
|
|
19
|
+
*
|
|
20
|
+
* @param date1 First date
|
|
21
|
+
* @param date2 Second date
|
|
22
|
+
* @returns True if date1 is after date2
|
|
23
|
+
*/
|
|
24
|
+
static isAfter(date1: Date, date2: Date): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Checks whether two dates fall on the same calendar day.
|
|
27
|
+
*
|
|
28
|
+
* @param date1 First date
|
|
29
|
+
* @param date2 Second date
|
|
30
|
+
* @returns True if both dates are on the same day
|
|
31
|
+
*/
|
|
32
|
+
static isSameDay(date1: Date, date2: Date): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Checks whether a list of dates is in ascending order (oldest → newest).
|
|
35
|
+
*
|
|
36
|
+
* @param dates Array of Date objects
|
|
37
|
+
* @returns true if dates are in ascending order
|
|
38
|
+
*/
|
|
39
|
+
static isAscendingDateList(dates: Date[]): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Checks whether a list of dates is in descending order (newest → oldest).
|
|
42
|
+
*
|
|
43
|
+
* @param dates Array of Date objects
|
|
44
|
+
* @returns true if dates are in descending order
|
|
45
|
+
*/
|
|
46
|
+
static isDescendingDateList(dates: Date[]): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Checks whether a date string strictly matches the given date format.
|
|
49
|
+
*
|
|
50
|
+
* @param dateStr input date string
|
|
51
|
+
* @param formatStr expected date format
|
|
52
|
+
* @returns true if date matches the format exactly, false otherwise
|
|
53
|
+
*
|
|
54
|
+
* Example:
|
|
55
|
+
* doesDateMatchFormat("02/10/2003", "dd/MM/yyyy") → true
|
|
56
|
+
* doesDateMatchFormat("2/10/2003", "dd/MM/yyyy") → false
|
|
57
|
+
*/
|
|
58
|
+
static isDateMatchFormat(dateStr: string, formatStr: string): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Checks whether a string matches a given regular expression.
|
|
61
|
+
*
|
|
62
|
+
* @param value Input string to test
|
|
63
|
+
* @param pattern Regular expression pattern
|
|
64
|
+
* @returns true if pattern matches, otherwise false
|
|
65
|
+
*
|
|
66
|
+
* Example:
|
|
67
|
+
* matchRegex("test@example.com", /^[^\s@]+@[^\s@]+\.[^\s@]+$/) → true
|
|
68
|
+
*/
|
|
69
|
+
static isMatchedRegex(value: string, pattern: RegExp): boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Validates whether the actual transaction/payment ID matches
|
|
72
|
+
* the expected partially visible and hidden (masked) pattern.
|
|
73
|
+
* @since 27-01-2026
|
|
74
|
+
* @param actualId String (Full transaction/payment ID)
|
|
75
|
+
* @param expectedId String (Expected masked transaction/payment ID)
|
|
76
|
+
* @returns true if the masked actual ID matches the expected ID, otherwise false
|
|
77
|
+
*/
|
|
78
|
+
static isTransactionIdMatchingPartialVisibleHiddenPattern(actualId: string, expectedId: string): boolean;
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=validationUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validationUtils.d.ts","sourceRoot":"","sources":["../../src/utils/validationUtils.ts"],"names":[],"mappings":"AAEA,qBAAa,eAAe;IACxB;;;;;OAKG;IACH,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO;IAQvC;;;;;;OAMG;IACH,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,GAAG,OAAO;IAQlD;;;;;;OAMG;IACH,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,GAAG,OAAO;IAQjD;;;;;;OAMG;IACH,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,GAAG,OAAO;IAcnD;;;;;OAKG;IACH,MAAM,CAAC,mBAAmB,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,OAAO;IAiBlD;;;;;OAKG;IACH,MAAM,CAAC,oBAAoB,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,OAAO;IAkBnD;;;;;;;;;;OAUG;IACH,MAAM,CAAC,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO;IAgBrE;;;;;;;;;OASG;IACH,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO;IAU9D;;;;;;;KAOC;IACH,MAAM,CAAC,kDAAkD,CACvD,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,GACjB,OAAO;CAKX"}
|