transit-core-taf 1.0.2 → 1.0.4
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/README.md +286 -0
- package/package.json +4 -7
- package/dist/transit-core-taf/base/basepageactions.d.ts +0 -178
- package/dist/transit-core-taf/base/basepageactions.js +0 -288
- package/dist/transit-core-taf/base/basepagevalidations.d.ts +0 -296
- package/dist/transit-core-taf/base/basepagevalidations.js +0 -459
- package/dist/transit-core-taf/base/basepagewaits.d.ts +0 -54
- package/dist/transit-core-taf/base/basepagewaits.js +0 -169
- package/dist/transit-core-taf/base/commonpageactions.d.ts +0 -40
- package/dist/transit-core-taf/base/commonpageactions.js +0 -118
- package/dist/transit-core-taf/base/commonpagevalidations.d.ts +0 -10
- package/dist/transit-core-taf/base/commonpagevalidations.js +0 -21
- package/dist/transit-core-taf/base/commonpagewaits.d.ts +0 -28
- package/dist/transit-core-taf/base/commonpagewaits.js +0 -57
- package/dist/transit-core-taf/base/logger.d.ts +0 -10
- package/dist/transit-core-taf/base/logger.js +0 -42
- package/dist/transit-core-taf/baseapi/apiutils.d.ts +0 -9
- package/dist/transit-core-taf/baseapi/apiutils.js +0 -23
- package/dist/transit-core-taf/baseapi/baseapihelpers.d.ts +0 -10
- package/dist/transit-core-taf/baseapi/baseapihelpers.js +0 -45
- package/dist/transit-core-taf/constants/apiconstants.d.ts +0 -29
- package/dist/transit-core-taf/constants/apiconstants.js +0 -38
- package/dist/transit-core-taf/constants/test-tags.d.ts +0 -14
- package/dist/transit-core-taf/constants/test-tags.js +0 -17
- package/dist/transit-core-taf/fixtures.d.ts +0 -23
- package/dist/transit-core-taf/fixtures.js +0 -81
- package/dist/transit-core-taf/global-setup.d.ts +0 -2
- package/dist/transit-core-taf/global-setup.js +0 -103
- package/dist/transit-core-taf/index.d.ts +0 -23
- package/dist/transit-core-taf/index.js +0 -39
- package/dist/transit-core-taf/steps/basepageactions.steps.d.ts +0 -1
- package/dist/transit-core-taf/steps/basepageactions.steps.js +0 -92
- package/dist/transit-core-taf/steps/basepagevalidations.steps.d.ts +0 -1
- package/dist/transit-core-taf/steps/basepagevalidations.steps.js +0 -59
- package/dist/transit-core-taf/steps/basepagewaits.steps.d.ts +0 -1
- package/dist/transit-core-taf/steps/basepagewaits.steps.js +0 -29
- package/dist/transit-core-taf/steps/commonpageactions.steps.d.ts +0 -1
- package/dist/transit-core-taf/steps/commonpageactions.steps.js +0 -18
- package/dist/transit-core-taf/steps/commonpagevalidations.steps.d.ts +0 -1
- package/dist/transit-core-taf/steps/commonpagevalidations.steps.js +0 -16
- package/dist/transit-core-taf/steps/commonpagewaits.steps.d.ts +0 -1
- package/dist/transit-core-taf/steps/commonpagewaits.steps.js +0 -24
- package/dist/transit-core-taf/steps/hooks.d.ts +0 -1
- package/dist/transit-core-taf/steps/hooks.js +0 -10
- package/dist/transit-core-taf/steps/world.d.ts +0 -12
- package/dist/transit-core-taf/steps/world.js +0 -37
- package/dist/transit-core-taf/utils/Utils.d.ts +0 -114
- package/dist/transit-core-taf/utils/Utils.js +0 -219
- package/dist/transit-core-taf/utils/envutils.d.ts +0 -2
- package/dist/transit-core-taf/utils/envutils.js +0 -55
- package/dist/transit-core-taf/utils/excelUtils.d.ts +0 -1
- package/dist/transit-core-taf/utils/excelUtils.js +0 -51
- package/dist/transit-core-taf/utils/networkutils.d.ts +0 -24
- package/dist/transit-core-taf/utils/networkutils.js +0 -53
|
@@ -1,288 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BasePageActions = void 0;
|
|
4
|
-
const basepagewaits_1 = require("./basepagewaits");
|
|
5
|
-
class BasePageActions {
|
|
6
|
-
page;
|
|
7
|
-
waits;
|
|
8
|
-
logger;
|
|
9
|
-
constructor(page, logger) {
|
|
10
|
-
this.page = page;
|
|
11
|
-
this.waits = new basepagewaits_1.BasePageWaits(page, logger);
|
|
12
|
-
this.logger = logger;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Waits for an element to be visible and clicks on it.
|
|
16
|
-
* Logs the action and provides an error message if the element isn't visible in time.
|
|
17
|
-
* @param element The locator of the element to click.
|
|
18
|
-
* @param timeout Optional timeout in ms to wait for visibility (default: 30s).
|
|
19
|
-
*/
|
|
20
|
-
async clickElement(element, timeout = 30000) {
|
|
21
|
-
try {
|
|
22
|
-
this.logger.info(`[Action] Waiting for element to be visible before clicking: ${element}`);
|
|
23
|
-
await element.waitFor({ state: 'visible', timeout });
|
|
24
|
-
this.logger.info(`[Action] Clicking on element: ${element}`);
|
|
25
|
-
await element.click({ timeout });
|
|
26
|
-
}
|
|
27
|
-
catch (error) {
|
|
28
|
-
this.logger.error(`[Error] Failed to click element. It was not visible within ${timeout}ms: ${element}`);
|
|
29
|
-
throw error;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Clicks an element using its locator.
|
|
34
|
-
* @param {Locator} element - The Playwright locator of the element to click.
|
|
35
|
-
* @param {Object} [options={}] - Click options.
|
|
36
|
-
* @param {number} [options.timeout=120000] - Maximum time to wait for the element.
|
|
37
|
-
* @param {boolean} [options.force=false] - Whether to force the click (useful if the element is not interactable).
|
|
38
|
-
*/
|
|
39
|
-
async clickByLocator(element, options = {}) {
|
|
40
|
-
const { timeout = 120000, force = false } = options;
|
|
41
|
-
this.logger.info(`Clicking by locator: ${element}`);
|
|
42
|
-
await element.waitFor({ state: 'visible', timeout });
|
|
43
|
-
await element.click({ timeout, force });
|
|
44
|
-
await this.waits.waitForDomContentLoad();
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Locates a button with the specified text on the page.
|
|
48
|
-
*
|
|
49
|
-
* Note: This function currently only creates the locator but does not perform a click.
|
|
50
|
-
*
|
|
51
|
-
* @param buttonText - The visible text of the button to locate.
|
|
52
|
-
*/
|
|
53
|
-
async clickButtonByText(buttonText, timeout = 60000) {
|
|
54
|
-
const button = this.page.locator('button', { hasText: buttonText });
|
|
55
|
-
await button.click({ timeout });
|
|
56
|
-
await this.waits.waitForPageLoad();
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Locates a button with the specified text on the page.
|
|
60
|
-
*
|
|
61
|
-
* Note: This function currently only creates the locator but does not perform a click.
|
|
62
|
-
*
|
|
63
|
-
* @param buttonText - The visible text of the button to locate.
|
|
64
|
-
*/
|
|
65
|
-
async clickById(id, clickIfVisible = false, timeout = 60000) {
|
|
66
|
-
this.logger.info(`Clicking by id: ${id}`);
|
|
67
|
-
const element = this.page.locator(`#${id}`);
|
|
68
|
-
try {
|
|
69
|
-
await element.waitFor({ state: 'visible', timeout });
|
|
70
|
-
if (clickIfVisible) {
|
|
71
|
-
if (await element.isVisible()) {
|
|
72
|
-
await element.click({ timeout });
|
|
73
|
-
await this.waits.waitForDomContentLoad();
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
await element.click({ timeout });
|
|
78
|
-
await this.waits.waitForDomContentLoad();
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
catch (error) {
|
|
82
|
-
this.logger.error(`Element with ID '${id}' was not visible within ${timeout} ms.`);
|
|
83
|
-
throw error;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Fills an input element with a given value.
|
|
88
|
-
* @param element The locator of the input element.
|
|
89
|
-
* @param value The value to fill the input with.
|
|
90
|
-
*/
|
|
91
|
-
async fillInput(element, value) {
|
|
92
|
-
await element.fill(value);
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Clears the value of an input element.
|
|
96
|
-
* @param element The locator of the input element.
|
|
97
|
-
*/
|
|
98
|
-
async clearInput(element) {
|
|
99
|
-
await element.fill('');
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Types a text into an element slowly, with a specified delay between keystrokes.
|
|
103
|
-
* @param element The locator of the element to type into.
|
|
104
|
-
* @param text The text to type.
|
|
105
|
-
* @param delay The delay between keystrokes in milliseconds (default is 100).
|
|
106
|
-
*/
|
|
107
|
-
async typeSlowly(element, text, delay = 100) {
|
|
108
|
-
await element.type(text, { delay });
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Hovers over a given element.
|
|
112
|
-
* @param element The locator of the element to hover over.
|
|
113
|
-
*/
|
|
114
|
-
async hoverOverElement(element, timeout = 20000) {
|
|
115
|
-
await element.waitFor({ state: 'visible', timeout });
|
|
116
|
-
await element.hover();
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Presses a key on a given element.
|
|
120
|
-
* @param element The locator of the element.
|
|
121
|
-
* @param key The key to press (e.g., 'Enter', 'ArrowDown').
|
|
122
|
-
*/
|
|
123
|
-
async pressKey(element, key) {
|
|
124
|
-
await element.press(key);
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Checks a checkbox if it is not already checked.
|
|
128
|
-
* @param element The locator of the checkbox element.
|
|
129
|
-
*/
|
|
130
|
-
async checkCheckbox(element) {
|
|
131
|
-
if (!(await element.isChecked())) {
|
|
132
|
-
await element.check();
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Unchecks a checkbox if it is already checked.
|
|
137
|
-
* @param element The locator of the checkbox element.
|
|
138
|
-
*/
|
|
139
|
-
async uncheckCheckbox(element) {
|
|
140
|
-
if (await element.isChecked()) {
|
|
141
|
-
await element.uncheck();
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Selects an option from a dropdown element by its value.
|
|
146
|
-
* @param element The locator of the select element.
|
|
147
|
-
* @param value The value of the option to select.
|
|
148
|
-
*/
|
|
149
|
-
async selectOption(element, value) {
|
|
150
|
-
await element.selectOption(value);
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Retrieves the text content of an element by its ID.
|
|
154
|
-
*
|
|
155
|
-
* @param id - The ID of the HTML element to retrieve text from.
|
|
156
|
-
* @returns The text content of the specified element.
|
|
157
|
-
*/
|
|
158
|
-
async getElementTextById(id) {
|
|
159
|
-
const text = (await this.page.locator(`#${id}`).textContent())?.toString();
|
|
160
|
-
return text;
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Retrieves the text content of an element by its Locator.
|
|
164
|
-
* @param locator - The Locator of the HTML element to retrieve text from.
|
|
165
|
-
* @returns The text content of the specified element.
|
|
166
|
-
*/
|
|
167
|
-
async getElementTextByLocator(locator) {
|
|
168
|
-
return (await locator.textContent()) ?? '';
|
|
169
|
-
}
|
|
170
|
-
/**Gets the specified attribute value of an element using its ID.
|
|
171
|
-
* @param id The ID of the element.
|
|
172
|
-
* @param attribute The attribute name (e.g., 'value', 'min', 'max')
|
|
173
|
-
*/
|
|
174
|
-
async getElementAttributeValueById(id, attribute) {
|
|
175
|
-
const locator = await this.page.locator(`#${id}`);
|
|
176
|
-
const attributeValue = (await locator.getAttribute(attribute))?.toString();
|
|
177
|
-
return attributeValue;
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Gets the specified attribute value of an element using a Locator.
|
|
181
|
-
* @param locator The Playwright Locator for the element.
|
|
182
|
-
* @param attribute The attribute name (e.g., 'value', 'min', 'max').
|
|
183
|
-
* @returns The attribute value as a string (or undefined if not present).
|
|
184
|
-
*/
|
|
185
|
-
async getAttributeValueByLocator(locator, attribute) {
|
|
186
|
-
const attributeValue = (await locator.getAttribute(attribute))?.toString();
|
|
187
|
-
return attributeValue;
|
|
188
|
-
}
|
|
189
|
-
/** Fills an input element identified by its ID with a given value.
|
|
190
|
-
* - Waits for the input to be visible before filling.
|
|
191
|
-
*
|
|
192
|
-
* @param elementId - The ID of the input element.
|
|
193
|
-
* @param value - The value to fill the input with.
|
|
194
|
-
*/
|
|
195
|
-
async fillInputById(elementId, value) {
|
|
196
|
-
const element = await this.page.locator(`#${elementId}`);
|
|
197
|
-
await element.waitFor({ state: 'visible' });
|
|
198
|
-
await element.fill(value);
|
|
199
|
-
}
|
|
200
|
-
/**
|
|
201
|
-
* Clicks a tab by its text and validates that it's selected using accessibility and style attributes.
|
|
202
|
-
* @param tabText - Visible text of the tab (e.g., "Crop").
|
|
203
|
-
* @param timeout - Optional timeout for the click action.
|
|
204
|
-
*/
|
|
205
|
-
async validateCropTabSelected(tabLocator, timeout = 60000) {
|
|
206
|
-
await tabLocator.click({ timeout });
|
|
207
|
-
await this.waits.waitForPageLoad();
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* Counts the number of objects in the array where the given key is null or undefined.
|
|
211
|
-
* @param items - The array of items to check.
|
|
212
|
-
* @param key - The key to inspect on each item.
|
|
213
|
-
* @returns The number of items where the key is null or undefined.
|
|
214
|
-
*/
|
|
215
|
-
async getNullCountByType(items, key) {
|
|
216
|
-
return items.filter((item) => item[key] == null).length;
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* Sets the viewport size and waits for DOM content to be loaded.
|
|
220
|
-
* @param viewport - An object with width and height properties.
|
|
221
|
-
*/
|
|
222
|
-
async setViewport(viewport) {
|
|
223
|
-
await this.page.setViewportSize(viewport);
|
|
224
|
-
await this.page.waitForLoadState('domcontentloaded');
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* Reloads the current page and waits until the DOM is fully loaded.
|
|
228
|
-
* @param options - Optional reload options (timeout, waitUntil).
|
|
229
|
-
*/
|
|
230
|
-
async reloadPage(options = { waitUntil: 'load' }) {
|
|
231
|
-
await this.page.reload(options);
|
|
232
|
-
}
|
|
233
|
-
/**
|
|
234
|
-
* Universal drag-and-drop method for builder elements (photos, layouts, backgrounds, stickers).
|
|
235
|
-
* Accepts either a string selector or a Playwright Locator for both source and target.
|
|
236
|
-
* @param source - Locator or string selector for the element to drag.
|
|
237
|
-
* @param target - Locator or string selector for the drop target.
|
|
238
|
-
* @param attribute - (Optional) Attribute to return from the dragged element (default: "data-id").
|
|
239
|
-
* @returns The attribute value if available, otherwise null.
|
|
240
|
-
*/
|
|
241
|
-
async dragElementToTarget(source, target, attribute = 'data-id') {
|
|
242
|
-
const toLocator = (input) => {
|
|
243
|
-
if (typeof input !== 'string')
|
|
244
|
-
return input;
|
|
245
|
-
if (/^(#|\.|\[)/.test(input)) {
|
|
246
|
-
return this.page.locator(input);
|
|
247
|
-
}
|
|
248
|
-
return this.page.locator(`#${input}`);
|
|
249
|
-
};
|
|
250
|
-
const sourceLocator = toLocator(source);
|
|
251
|
-
const targetLocator = toLocator(target);
|
|
252
|
-
await sourceLocator.waitFor({ state: 'visible' });
|
|
253
|
-
await targetLocator.waitFor({ state: 'visible' });
|
|
254
|
-
const attrValue = await sourceLocator.getAttribute(attribute);
|
|
255
|
-
await sourceLocator.dragTo(targetLocator);
|
|
256
|
-
return attrValue;
|
|
257
|
-
}
|
|
258
|
-
/**
|
|
259
|
-
* Gives the textcontent of all elements .
|
|
260
|
-
* @param locator The ID of the element.
|
|
261
|
-
* Returns array of values of all the elements textcontent
|
|
262
|
-
*/
|
|
263
|
-
async getAllTextContents(locator) {
|
|
264
|
-
const textContent = await locator.allTextContents();
|
|
265
|
-
return textContent;
|
|
266
|
-
}
|
|
267
|
-
/**
|
|
268
|
-
* @param locator The ID of the element.
|
|
269
|
-
* Click on element if its not expanded
|
|
270
|
-
*/
|
|
271
|
-
async clickIfNotExpanded(locator) {
|
|
272
|
-
const isExpanded = await locator.getAttribute('aria-expanded');
|
|
273
|
-
if (isExpanded !== 'true') {
|
|
274
|
-
await locator.click();
|
|
275
|
-
await this.waits.waitForDomContentLoad();
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
/**
|
|
279
|
-
* Performs a mouse click at the given screen coordinates.
|
|
280
|
-
* @param x - The x-coordinate for the click.
|
|
281
|
-
* @param y - The y-coordinate for the click.
|
|
282
|
-
* @param options - Optional click options like button or clickCount.
|
|
283
|
-
*/
|
|
284
|
-
async mouseClickAt(x, y, options = {}) {
|
|
285
|
-
await this.page.mouse.click(x, y, options);
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
exports.BasePageActions = BasePageActions;
|
|
@@ -1,296 +0,0 @@
|
|
|
1
|
-
import { Locator, Page } from '@playwright/test';
|
|
2
|
-
import { Logger } from './logger';
|
|
3
|
-
export declare class BasePageValidations {
|
|
4
|
-
private page;
|
|
5
|
-
private logger;
|
|
6
|
-
constructor(page: Page, logger: Logger);
|
|
7
|
-
/**
|
|
8
|
-
* Validates that a given element is visible.
|
|
9
|
-
* @param element The locator of the element to validate.
|
|
10
|
-
*/
|
|
11
|
-
validateElementToBeVisible(element: Locator): Promise<void>;
|
|
12
|
-
/**
|
|
13
|
-
* Validates that a given element is not visible.
|
|
14
|
-
* This method asserts that the element exists in the DOM but is not currently visible.
|
|
15
|
-
* Visibility is determined based on factors such as CSS properties like `display: none`,
|
|
16
|
-
* `visibility: hidden`, or being off-screen.
|
|
17
|
-
* @param element The locator of the element to validate.
|
|
18
|
-
* @throws Will throw an assertion error if the element is visible.
|
|
19
|
-
*/
|
|
20
|
-
validateElementNotToBeVisible(element: Locator): Promise<void>;
|
|
21
|
-
/**
|
|
22
|
-
* Validates that the number of elements matching the locator is equal to the expected count.
|
|
23
|
-
* @param locator - The Playwright Locator pointing to the elements.
|
|
24
|
-
* @param expectedCount - The expected number of elements.
|
|
25
|
-
* Example:
|
|
26
|
-
* await validateElementCountToBe(page.locator('.item'), 3);
|
|
27
|
-
* */
|
|
28
|
-
validateElementCountToBe(locator: Locator, expectedCount: number): Promise<void>;
|
|
29
|
-
/**
|
|
30
|
-
* Validates that two elements are not overlapping.
|
|
31
|
-
* @param element1 The first locator.
|
|
32
|
-
* @param element2 The second locator.
|
|
33
|
-
*/
|
|
34
|
-
validateElementsDoNotOverlap(element1: Locator, element2: Locator): Promise<void>;
|
|
35
|
-
/**
|
|
36
|
-
* Waits for an element with the given ID to appear in the DOM within the specified timeout,
|
|
37
|
-
* and then validates that the element is visible.
|
|
38
|
-
*
|
|
39
|
-
* @param id - The ID of the element to validate visibility for.
|
|
40
|
-
* @param timeout - Maximum time to wait for the element to appear (in milliseconds). Defaults to 10 seconds.
|
|
41
|
-
*/
|
|
42
|
-
validateElementToBeVisibleById(id: string, timeout?: number): Promise<void>;
|
|
43
|
-
/** Validates that a given element is visible and contains the expected text.
|
|
44
|
-
* @param element - The Playwright Locator for the element to validate.
|
|
45
|
-
* @param expectedText - The exact text expected to be present in the element.
|
|
46
|
-
* @param timeout - Optional timeout (in ms) to wait for visibility and text match. Default is 60 seconds.
|
|
47
|
-
* await validations.validateElementToHaveText(page.locator('.success-message'), 'Upload Complete');
|
|
48
|
-
*/
|
|
49
|
-
validateElementToHaveText(element: Locator | string, expectedText: string, timeout?: number): Promise<void>;
|
|
50
|
-
/**
|
|
51
|
-
* Validates that a given element has the expected text.
|
|
52
|
-
* @param element The locator of the element to validate.
|
|
53
|
-
* @param expectedText The expected text of the element.
|
|
54
|
-
*/
|
|
55
|
-
validateText(actualText?: string, expectedText?: string | number): Promise<void>;
|
|
56
|
-
/**
|
|
57
|
-
* Validates that a given element has the expected text.
|
|
58
|
-
* @param element The locator of the element to validate.
|
|
59
|
-
* @param expectedText The expected text of the element.
|
|
60
|
-
*/
|
|
61
|
-
validateTextNotToBe(actualText?: string, expectedText?: string | number): Promise<void>;
|
|
62
|
-
/**
|
|
63
|
-
* Validates that a given element is enabled.
|
|
64
|
-
* @param element The locator of the element to validate.
|
|
65
|
-
*/
|
|
66
|
-
validateElementToBeEnabled(element: Locator): Promise<void>;
|
|
67
|
-
/**
|
|
68
|
-
* Validates that a given element is hidden.
|
|
69
|
-
* @param element The locator of the element to validate.
|
|
70
|
-
*/
|
|
71
|
-
validateElementToBeHidden(element: Locator): Promise<void>;
|
|
72
|
-
/**
|
|
73
|
-
* Validates that multiple elements are hidden.
|
|
74
|
-
* @param elements Array of Playwright locators to validate.
|
|
75
|
-
*/
|
|
76
|
-
validateElementsToBeHidden(elements: Locator[]): Promise<void>;
|
|
77
|
-
/**
|
|
78
|
-
* Validates that a given element (Locator or string ID) has a specific attribute with a specific value.
|
|
79
|
-
* @param element - The element to validate (Playwright Locator or string ID).
|
|
80
|
-
* @param attr - The attribute to check.
|
|
81
|
-
* @param value - The expected value of the attribute.
|
|
82
|
-
* @param timeout - Optional timeout in milliseconds (default: 10s).
|
|
83
|
-
*/
|
|
84
|
-
validateElementToHaveAttribute(element: Locator | string, attr: string, value: string, timeout?: number): Promise<void>;
|
|
85
|
-
/**
|
|
86
|
-
* Validates that a given element contains the expected text (partial or regex).
|
|
87
|
-
* @param element The locator or string ID of the element.
|
|
88
|
-
* @param expectedText The expected partial text or RegExp to be found in the element.
|
|
89
|
-
* @param timeout Maximum time to wait for the element to become visible and contain the text (default: 60s).
|
|
90
|
-
*/
|
|
91
|
-
validateElementToContainText(element: Locator | string, expectedText: string | RegExp, timeout?: number): Promise<void>;
|
|
92
|
-
/**
|
|
93
|
-
* Checks if an element with the given ID is visible on the page.
|
|
94
|
-
* This method runs inside the browser context using `page.evaluate` to:
|
|
95
|
-
* - Find the DOM element using `getElementById`.
|
|
96
|
-
* - Return false if the element doesn't exist.
|
|
97
|
-
* - Otherwise, check if the element's `display` style is not set to `"none"`,
|
|
98
|
-
* which indicates whether the element is visible or hidden via CSS.
|
|
99
|
-
* @param elementId - The ID of the element to check visibility for.
|
|
100
|
-
* @returns A promise that resolves to `true` if the element is visible,
|
|
101
|
-
* or `false` if it's hidden or not found.
|
|
102
|
-
*/
|
|
103
|
-
isElementVisible(elementId: string): Promise<boolean>;
|
|
104
|
-
/**
|
|
105
|
-
* Checks if an element with the given ID is visible on the page using Playwright commands.
|
|
106
|
-
* It asserts that the element is visible within the given timeout.
|
|
107
|
-
*
|
|
108
|
-
* @param elementId - The ID of the element to check.
|
|
109
|
-
* @param timeout - The maximum time to wait for the element to become visible (in ms). Default is 5000 ms.
|
|
110
|
-
*/
|
|
111
|
-
validateElementVisibleById(elementId: string, timeout?: number): Promise<void>;
|
|
112
|
-
/**
|
|
113
|
-
* Validates that a value is null.
|
|
114
|
-
* @param actual The actual value to check.
|
|
115
|
-
*/
|
|
116
|
-
validateValueToBeNull(actual: any): Promise<void>;
|
|
117
|
-
/**
|
|
118
|
-
* Validates that a value is not null.
|
|
119
|
-
* @param actual The actual value to check.
|
|
120
|
-
*/
|
|
121
|
-
validateValueNotToBeNull(actual: any): Promise<void>;
|
|
122
|
-
/**
|
|
123
|
-
* Validates that a value is greater than the expected value.
|
|
124
|
-
* @param actual The actual number.
|
|
125
|
-
* @param expected The number to compare against.
|
|
126
|
-
*/
|
|
127
|
-
validateValueToBeGreaterThan(actual: number, expected: number): Promise<void>;
|
|
128
|
-
/**
|
|
129
|
-
* Validates that a value is less than or equal to the expected value.
|
|
130
|
-
* @param actual The actual number.
|
|
131
|
-
* @param expected The number to compare against.
|
|
132
|
-
*/
|
|
133
|
-
validateValueToBeLessThanOrEqual(actual: number, expected: number): Promise<void>;
|
|
134
|
-
/**
|
|
135
|
-
* Validates that the actual value is equal to the expected value.
|
|
136
|
-
* @param actual - The actual value.
|
|
137
|
-
* @param expected - The expected value to compare.
|
|
138
|
-
* @param message - Optional custom message for assertion failure.
|
|
139
|
-
*/
|
|
140
|
-
validateValueToEqual(actual: any, expected: any, message?: string): Promise<void>;
|
|
141
|
-
/**
|
|
142
|
-
* Validates that the actual value is NOT equal to the expected value.
|
|
143
|
-
* @param actual - The actual value.
|
|
144
|
-
* @param expected - The value that should not match.
|
|
145
|
-
* @param message - Optional custom message for assertion failure.
|
|
146
|
-
*/
|
|
147
|
-
validateValueNotToEqual(actual: any, expected: any, message?: string): Promise<void>;
|
|
148
|
-
/**
|
|
149
|
-
* Validates that the actual number is less than the expected number.
|
|
150
|
-
* @param actual - The actual number.
|
|
151
|
-
* @param expected - The number to compare against.
|
|
152
|
-
*/
|
|
153
|
-
validateValueToBeLessThan(actual: number, expected: number): Promise<void>;
|
|
154
|
-
/**
|
|
155
|
-
* Validates that the actual value is truthy.
|
|
156
|
-
* @param actual - The value to validate.
|
|
157
|
-
*/
|
|
158
|
-
validateValueToBeTruthy(actual: any): Promise<void>;
|
|
159
|
-
/**
|
|
160
|
-
* Validates that the actual value is falsy.
|
|
161
|
-
* @param actual - The value to validate.
|
|
162
|
-
*/
|
|
163
|
-
validateValueToBeFalsy(actual: any): Promise<void>;
|
|
164
|
-
/**
|
|
165
|
-
* Validates that the actual array or string contains the expected item or substring.
|
|
166
|
-
* @param actual - The array or string.
|
|
167
|
-
* @param expected - The item or substring to check for.
|
|
168
|
-
*/
|
|
169
|
-
validateValueToContain(actual: any[] | string, expected: any): Promise<void>;
|
|
170
|
-
/**
|
|
171
|
-
* Validates that the actual string matches the given regular expression or substring.
|
|
172
|
-
* @param actual - The string to validate.
|
|
173
|
-
* @param expected - The regular expression or substring.
|
|
174
|
-
*/
|
|
175
|
-
validateValueToMatch(actual: string, expected: string | RegExp): Promise<void>;
|
|
176
|
-
/**
|
|
177
|
-
* Compares two arrays for equality (order-sensitive) using Playwright's expect.
|
|
178
|
-
* @param expected The expected array values.
|
|
179
|
-
* @param actual The actual array values.
|
|
180
|
-
* @param message Optional message for error context.
|
|
181
|
-
*/
|
|
182
|
-
validateArrayTextValues(expected: any[], actual: any[], message?: string): Promise<void>;
|
|
183
|
-
/**
|
|
184
|
-
* Compares two objects containing arrays (order-sensitive) using Playwright's expect.
|
|
185
|
-
* Each key in the object is compared individually with soft assertions.
|
|
186
|
-
* @param expected The expected object with array values.
|
|
187
|
-
* @param actual The actual object with array values.
|
|
188
|
-
* @param message Optional message for error context.
|
|
189
|
-
*/
|
|
190
|
-
validateObjectOfArrayTextValues(expected: {
|
|
191
|
-
[key: string]: string[];
|
|
192
|
-
}, actual: {
|
|
193
|
-
[key: string]: string[];
|
|
194
|
-
}, message?: string): Promise<void>;
|
|
195
|
-
/**
|
|
196
|
-
* Validates that the current page URL contains the expected string.
|
|
197
|
-
* Useful when the URL may include dynamic query parameters or fragments.
|
|
198
|
-
* @param expectedUrl - The expected substring to be present in the current URL.
|
|
199
|
-
*/
|
|
200
|
-
validateUrlToMatch(endpoint: RegExp): Promise<void>;
|
|
201
|
-
/**
|
|
202
|
-
* Validates that the current page URL starts with the expected string.
|
|
203
|
-
* Useful when the URL has dynamic query parameters.
|
|
204
|
-
* @param expectedUrl - The expected base URL (without query params).
|
|
205
|
-
*/
|
|
206
|
-
validateUrlToContain(expectedUrl: string): Promise<void>;
|
|
207
|
-
/**
|
|
208
|
-
* Validates that the element has the expected class name.
|
|
209
|
-
* @param locator - The element locator.
|
|
210
|
-
* @param expected - The class name to match (string or RegExp).
|
|
211
|
-
*/
|
|
212
|
-
validateLocatorToHaveClass(locator: Locator, expected: string | RegExp): Promise<void>;
|
|
213
|
-
/** Validates all visible crop drag handles have correct accessibility attributes.
|
|
214
|
-
* Skips any handles that are not currently visible.
|
|
215
|
-
* @param page - Playwright Page instance
|
|
216
|
-
*/
|
|
217
|
-
validateCropDragHandles(page: Page): Promise<void>;
|
|
218
|
-
/**
|
|
219
|
-
* Validates if a given value is true or false.
|
|
220
|
-
* @param actual - The actual boolean value or a function that returns a boolean.
|
|
221
|
-
* @param expected - Expected boolean value (true or false).
|
|
222
|
-
* @param message - Optional custom error message on failure.
|
|
223
|
-
*/
|
|
224
|
-
validateToBeBoolean(actual: boolean | (() => Promise<boolean> | boolean), expected: boolean, message?: string): Promise<void>;
|
|
225
|
-
/**
|
|
226
|
-
* Validates that a given element has the specified class or matches the given class pattern.
|
|
227
|
-
* @param element The locator of the element to validate.
|
|
228
|
-
* @param expectedClass The expected class name or regex pattern.
|
|
229
|
-
*/
|
|
230
|
-
validateElementToHaveClass(element: Locator | string, expected: string | RegExp): Promise<void>;
|
|
231
|
-
/**
|
|
232
|
-
* Validates that a given element has the expected CSS class.
|
|
233
|
-
* @param element The locator of the element to validate.
|
|
234
|
-
* @param expectedClass The class name expected to be present on the element.
|
|
235
|
-
*/
|
|
236
|
-
validateElementToContainClass(element: Locator, expectedClass: string): Promise<void>;
|
|
237
|
-
/**
|
|
238
|
-
* Validates that an asynchronous condition passes within a given timeout.
|
|
239
|
-
* @param condition A function that returns a promise to be resolved.
|
|
240
|
-
* @param timeout The timeout for the condition to pass.
|
|
241
|
-
*/
|
|
242
|
-
validateAsyncCondition(condition: () => Promise<void>, timeout: number): Promise<void>;
|
|
243
|
-
/**
|
|
244
|
-
* Validates that a given element has the expected CSS property and value.
|
|
245
|
-
* @param locator The locator of the element to validate.
|
|
246
|
-
* @param cssProperty The CSS property to check.
|
|
247
|
-
* @param expectedValue The expected value of the CSS property.
|
|
248
|
-
*/
|
|
249
|
-
validateElementToHaveCSS(locator: Locator, cssProperty: string, expectedValue: string | RegExp): Promise<void>;
|
|
250
|
-
/**
|
|
251
|
-
* Validates that the actual value is equal to the expected value.
|
|
252
|
-
* @param actual - The actual value.
|
|
253
|
-
* @param expected - The expected value to compare.
|
|
254
|
-
*/
|
|
255
|
-
validateValueToBe(actual: any, expected: any): Promise<void>;
|
|
256
|
-
/**
|
|
257
|
-
* Gets the value of a given attribute from a locator.
|
|
258
|
-
* @param locator - Playwright Locator for the element.
|
|
259
|
-
* @param attributeName - The attribute name to fetch (e.g., "aria-checked", "data-id").
|
|
260
|
-
* @returns Promise resolving to the attribute value or null if not present.
|
|
261
|
-
*/
|
|
262
|
-
getAttributeValueByLocator(locator: Locator, attributeName: string): Promise<string | null>;
|
|
263
|
-
/**
|
|
264
|
-
* Validates that the given element does NOT have the specified attribute value.
|
|
265
|
-
* If the attribute is missing, the check passes.
|
|
266
|
-
* If the attribute exists, its value must not equal the provided one.
|
|
267
|
-
* @param element Locator of the element to validate
|
|
268
|
-
* @param attr Attribute name to check (e.g., "class", "disabled")
|
|
269
|
-
* @param value Attribute value that should NOT be present
|
|
270
|
-
*/
|
|
271
|
-
validateElementNotToHaveAttributeValue(element: Locator, attr: string, value: string): Promise<void>;
|
|
272
|
-
/**
|
|
273
|
-
* Validates that all layered file names exist in the photo tray file names.
|
|
274
|
-
* @param photoTrayFileNames - Array of file names currently available in the photo tray.
|
|
275
|
-
* @param layeredFileNames - Array of file names that are layered/applied on the canvas.
|
|
276
|
-
* The function ensures integrity between the canvas and the photo tray,
|
|
277
|
-
* by checking that every layered file originates from the photo tray.
|
|
278
|
-
*/
|
|
279
|
-
validateValuesToContain(photoTrayFileNames: string[], layeredFileNames: string[]): Promise<void>;
|
|
280
|
-
/**
|
|
281
|
-
* Validates that multiple elements are visible on the page.
|
|
282
|
-
* @param {Locator[]} elements - Array of Playwright locators to validate.
|
|
283
|
-
* @returns {Promise<void>} Resolves when all elements are confirmed visible.
|
|
284
|
-
*/
|
|
285
|
-
validateElementsToBeVisible(elements: Locator[]): Promise<void>;
|
|
286
|
-
/** Waits until a given element is visible in the DOM.
|
|
287
|
-
* @param element - The Playwright Locator of the element to wait for.
|
|
288
|
-
* @param timeout - Optional timeout in ms (default: 10s).
|
|
289
|
-
*/
|
|
290
|
-
waitForElementVisible(element: Locator, timeout?: number): Promise<void>;
|
|
291
|
-
/**
|
|
292
|
-
* Checks if given elements have expected text.
|
|
293
|
-
* Accepts either locator or string ID.
|
|
294
|
-
*/
|
|
295
|
-
validateElementsToHaveText(locators: any[], expectedTexts: string[]): Promise<void>;
|
|
296
|
-
}
|