transit-core-taf 1.0.4 → 1.0.5
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/transit-core-taf/baseapi/apiutils.d.ts +9 -0
- package/dist/transit-core-taf/baseapi/apiutils.js +23 -0
- package/dist/transit-core-taf/baseapi/baseapihelpers.d.ts +10 -0
- package/dist/transit-core-taf/baseapi/baseapihelpers.js +45 -0
- package/dist/transit-core-taf/baseui/basepageactions.d.ts +178 -0
- package/dist/transit-core-taf/baseui/basepageactions.js +288 -0
- package/dist/transit-core-taf/baseui/basepagevalidations.d.ts +309 -0
- package/dist/transit-core-taf/baseui/basepagevalidations.js +478 -0
- package/dist/transit-core-taf/baseui/basepagewaits.d.ts +54 -0
- package/dist/transit-core-taf/baseui/basepagewaits.js +169 -0
- package/dist/transit-core-taf/baseui/commonpageactions.d.ts +40 -0
- package/dist/transit-core-taf/baseui/commonpageactions.js +118 -0
- package/dist/transit-core-taf/baseui/commonpagevalidations.d.ts +10 -0
- package/dist/transit-core-taf/baseui/commonpagevalidations.js +21 -0
- package/dist/transit-core-taf/baseui/commonpagewaits.d.ts +28 -0
- package/dist/transit-core-taf/baseui/commonpagewaits.js +57 -0
- package/dist/transit-core-taf/baseui/logger.d.ts +10 -0
- package/dist/transit-core-taf/baseui/logger.js +42 -0
- package/dist/transit-core-taf/constants/test-tags.d.ts +4 -0
- package/dist/transit-core-taf/constants/test-tags.js +7 -0
- package/dist/transit-core-taf/fixtures.d.ts +20 -0
- package/dist/transit-core-taf/fixtures.js +58 -0
- package/dist/transit-core-taf/global-setup.d.ts +2 -0
- package/dist/transit-core-taf/global-setup.js +103 -0
- package/dist/transit-core-taf/index.d.ts +11 -0
- package/dist/transit-core-taf/index.js +27 -0
- package/dist/transit-core-taf/utils/Utils.d.ts +114 -0
- package/dist/transit-core-taf/utils/Utils.js +219 -0
- package/package.json +7 -4
- package/README.md +0 -286
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BasePageWaits = void 0;
|
|
4
|
+
class BasePageWaits {
|
|
5
|
+
page;
|
|
6
|
+
logger;
|
|
7
|
+
constructor(page, logger) {
|
|
8
|
+
this.page = page;
|
|
9
|
+
this.logger = logger;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Waits for the page to be fully loaded.
|
|
13
|
+
*/
|
|
14
|
+
async waitForPageLoad(timeout = 240000) {
|
|
15
|
+
this.logger.info("Waiting for page to load...");
|
|
16
|
+
await this.page.waitForLoadState('domcontentloaded', { timeout });
|
|
17
|
+
try {
|
|
18
|
+
// await this.page.waitForLoadState('networkidle', { timeout });
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
if (error instanceof Error && error.message.includes('timeout')) {
|
|
22
|
+
this.logger.warn(`Network idle state not reached within ${timeout / 1000}s. Continuing...`);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
throw error;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
async waitForDomContentLoad() {
|
|
30
|
+
this.logger.info("Waiting for DOM content to load...");
|
|
31
|
+
await this.page.waitForLoadState('domcontentloaded');
|
|
32
|
+
}
|
|
33
|
+
async waitForNetworkIdle() {
|
|
34
|
+
await this.page.waitForLoadState('networkidle');
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Waits for either DOM content to load or the full page to load, based on the provided flag.
|
|
38
|
+
* @param {boolean} [waitForDomOnly=false] -
|
|
39
|
+
* If true, waits only for DOM content to be loaded using `waitForDomContentLoad()`.
|
|
40
|
+
* If false (default), waits for the full page load using `waitForPageLoad()`.
|
|
41
|
+
* This method is useful when navigating between pages or clicking links where
|
|
42
|
+
* you want to optimize waiting time based on the expected load behavior.
|
|
43
|
+
*/
|
|
44
|
+
async waitForPageLoadOnCondition(waitForDomOnly = false) {
|
|
45
|
+
if (waitForDomOnly) {
|
|
46
|
+
await this.waitForDomContentLoad();
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
await this.waitForPageLoad();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Waits for a specified number of seconds.
|
|
54
|
+
* @param seconds The number of seconds to wait.
|
|
55
|
+
*/
|
|
56
|
+
async waitForSeconds(seconds) {
|
|
57
|
+
this.logger.info(`Waiting for ${seconds} seconds...`);
|
|
58
|
+
await this.page.waitForTimeout(seconds * 1000);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Navigates to a URL and waits for the page to load.
|
|
62
|
+
* @param url The URL to navigate to.
|
|
63
|
+
*/
|
|
64
|
+
async goto(url) {
|
|
65
|
+
await this.page.goto(url);
|
|
66
|
+
await this.waitForPageLoad();
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Checks if an element is visible on the page.
|
|
70
|
+
* @param selector The selector of the element to check.
|
|
71
|
+
* @returns A promise that resolves to true if the element is visible, and false otherwise.
|
|
72
|
+
*/
|
|
73
|
+
async isElementVisible(selector) {
|
|
74
|
+
return await this.page.locator(selector).isVisible();
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Waits for the progress spinner to become invisible.
|
|
78
|
+
* The spinner is identified by the '#progress-status' selector, and this method
|
|
79
|
+
* is robust against the changing text within the spinner.
|
|
80
|
+
*/
|
|
81
|
+
async waitForProgressSpinnerInvisibility() {
|
|
82
|
+
const spinnerSelector = '#progress-status';
|
|
83
|
+
try {
|
|
84
|
+
await this.page.waitForSelector(spinnerSelector, { state: 'hidden', timeout: 240000 });
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
if (error instanceof Error && error.message.includes('timeout')) {
|
|
88
|
+
this.logger.warn(`Progress spinner did not become invisible within 240 seconds.`);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
throw error;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
async waitFoPhotosUploadingSpinnerInvisibility() {
|
|
96
|
+
const preparingPhotosSelector = this.page.getByText(/Preparing Photos...Uploading \d+ Photos/);
|
|
97
|
+
try {
|
|
98
|
+
await preparingPhotosSelector.waitFor({ state: 'hidden', timeout: 240000 });
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
if (error instanceof Error && error.message.includes('timeout')) {
|
|
102
|
+
this.logger.warn(`Uploading spinner did not become invisible within 240 seconds.`);
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
throw error;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
async waitForLeftWellSpinnerInvisibility() {
|
|
110
|
+
const spinnerSelector = '#transparent-well-overlay';
|
|
111
|
+
try {
|
|
112
|
+
await this.page.waitForSelector(spinnerSelector, { state: 'hidden', timeout: 240000 });
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
if (error instanceof Error && error.message.includes('timeout')) {
|
|
116
|
+
this.logger.warn(`Left well spinner did not become invisible within 240 seconds.`);
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
throw error;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
async waitForSaveToBeSuccessful(timeout) {
|
|
124
|
+
const saveTooltip = this.page.locator('#save-tooltip');
|
|
125
|
+
await saveTooltip.waitFor({ state: 'visible', timeout });
|
|
126
|
+
const message = this.page.locator('div.tooltip-gl__box:has-text("Your project was successfully saved")');
|
|
127
|
+
await message.waitFor({ state: 'visible', timeout });
|
|
128
|
+
await saveTooltip.waitFor({ state: 'hidden', timeout });
|
|
129
|
+
}
|
|
130
|
+
async waitForApplyLayoutsToAllPages() {
|
|
131
|
+
const overlaySelector = '#transparent-page-overlay';
|
|
132
|
+
try {
|
|
133
|
+
// Wait for the overlay to disappear (opacity = 0)
|
|
134
|
+
await this.page.waitForFunction((selector) => {
|
|
135
|
+
const element = document.querySelector(selector);
|
|
136
|
+
if (element) {
|
|
137
|
+
const style = window.getComputedStyle(element);
|
|
138
|
+
return parseFloat(style.opacity) === 0;
|
|
139
|
+
}
|
|
140
|
+
return true; // If element is gone, it's also considered "disappeared"
|
|
141
|
+
}, overlaySelector, { timeout: 240000 } // 4 minutes timeout for it to disappear
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
catch (error) {
|
|
145
|
+
if (error instanceof Error && error.message.includes('timeout')) {
|
|
146
|
+
this.logger.warn(`Apply layouts to all pages overlay did not become transparent within the timeout.`);
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
throw error;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Waits for a given element to be visible on the page.
|
|
155
|
+
* @param element - The Playwright Locator of the element to wait for.
|
|
156
|
+
* @param timeout - Optional timeout in milliseconds (default: 5000).
|
|
157
|
+
*/
|
|
158
|
+
async waitForElementToBeVisible(element, timeout = 10000) {
|
|
159
|
+
try {
|
|
160
|
+
this.logger.info(`🔍 Waiting for element to be visible: ${element.toString()} (timeout: ${timeout}ms)`);
|
|
161
|
+
await element.waitFor({ state: 'visible', timeout });
|
|
162
|
+
}
|
|
163
|
+
catch (error) {
|
|
164
|
+
this.logger.error(`❌ Failed to find visible element: ${element.toString()} within ${timeout}ms`);
|
|
165
|
+
throw error;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
exports.BasePageWaits = BasePageWaits;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Locator, Page } from '@playwright/test';
|
|
2
|
+
import { Logger } from './logger';
|
|
3
|
+
export declare class CommonPageActions {
|
|
4
|
+
private page;
|
|
5
|
+
private waits;
|
|
6
|
+
constructor(page: Page, logger: Logger);
|
|
7
|
+
/**
|
|
8
|
+
* Click on an element if it's not expanded.
|
|
9
|
+
* @param locator The locator of the element.
|
|
10
|
+
*/
|
|
11
|
+
clickIfNotExpanded(locator: Locator): Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* Clicks an element without waiting for a full page load or network idle.
|
|
14
|
+
* This is ideal for clicking on-page elements like tabs that don't trigger navigation.
|
|
15
|
+
* @param element The locator of the element to click.
|
|
16
|
+
* @param timeout Optional timeout in ms.
|
|
17
|
+
*/
|
|
18
|
+
clickElementOnly(element: Locator, timeout?: number): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Removes the cookie consent popup from the DOM.
|
|
21
|
+
*/
|
|
22
|
+
acceptCookiePopup(): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Accepts the Transcend consent banner if it is visible.
|
|
25
|
+
*/
|
|
26
|
+
acceptTranscendConsent(): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Performs a robust, manual drag-and-drop by simulating mouse actions.
|
|
29
|
+
* This is useful for complex UIs where `dragTo` might fail.
|
|
30
|
+
* @param source The locator of the element to drag.
|
|
31
|
+
* @param target The locator of the drop target.
|
|
32
|
+
*/
|
|
33
|
+
dragAndDrop(source: Locator, target: Locator): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Waits for a given element to be hidden on the page.
|
|
36
|
+
* @param element - The Playwright Locator of the element to wait for.
|
|
37
|
+
* @param timeout - Optional timeout in milliseconds (default: 10000).
|
|
38
|
+
*/
|
|
39
|
+
waitForElementToBeHidden(element: Locator, timeout?: number): Promise<void>;
|
|
40
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CommonPageActions = void 0;
|
|
4
|
+
const basepagewaits_1 = require("./basepagewaits");
|
|
5
|
+
class CommonPageActions {
|
|
6
|
+
page;
|
|
7
|
+
waits;
|
|
8
|
+
constructor(page, logger) {
|
|
9
|
+
this.page = page;
|
|
10
|
+
this.waits = new basepagewaits_1.BasePageWaits(page, logger);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Click on an element if it's not expanded.
|
|
14
|
+
* @param locator The locator of the element.
|
|
15
|
+
*/
|
|
16
|
+
async clickIfNotExpanded(locator) {
|
|
17
|
+
const isExpanded = await locator.getAttribute('aria-expanded');
|
|
18
|
+
if (isExpanded !== 'true') {
|
|
19
|
+
await locator.click();
|
|
20
|
+
await this.waits.waitForDomContentLoad();
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Clicks an element without waiting for a full page load or network idle.
|
|
25
|
+
* This is ideal for clicking on-page elements like tabs that don't trigger navigation.
|
|
26
|
+
* @param element The locator of the element to click.
|
|
27
|
+
* @param timeout Optional timeout in ms.
|
|
28
|
+
*/
|
|
29
|
+
async clickElementOnly(element, timeout = 30000) {
|
|
30
|
+
console.log(`[Action] Clicking element without page load wait: ${element}`);
|
|
31
|
+
await element.waitFor({ state: 'visible', timeout });
|
|
32
|
+
await element.click({ timeout });
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Removes the cookie consent popup from the DOM.
|
|
36
|
+
*/
|
|
37
|
+
async acceptCookiePopup() {
|
|
38
|
+
console.log('Attempting to accept cookie popup by clicking "OKAY"');
|
|
39
|
+
try {
|
|
40
|
+
/**First, try to click the "OKAY" button */
|
|
41
|
+
const okayButton = this.page.locator('button:has-text("OKAY")');
|
|
42
|
+
await okayButton.waitFor({ state: 'visible', timeout: 5000 });
|
|
43
|
+
await okayButton.click();
|
|
44
|
+
console.log('Successfully clicked "OKAY" on the cookie popup.');
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
/** If clicking "OKAY" fails, fall back to the original DOM removal method */
|
|
48
|
+
console.log('Could not find or click "OKAY" button, falling back to DOM removal.');
|
|
49
|
+
await this.page.evaluate(() => {
|
|
50
|
+
const el = document.getElementById('transcend-consent-manager');
|
|
51
|
+
if (el) {
|
|
52
|
+
el.remove();
|
|
53
|
+
console.log('Removed transcend-consent-manager element as a fallback.');
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
console.log('transcend-consent-manager element not found for removal.');
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Accepts the Transcend consent banner if it is visible.
|
|
63
|
+
*/
|
|
64
|
+
async acceptTranscendConsent() {
|
|
65
|
+
const consentManager = this.page
|
|
66
|
+
.locator('#transcend-consent-manager')
|
|
67
|
+
.first();
|
|
68
|
+
if (await consentManager.isVisible()) {
|
|
69
|
+
await this.page.locator('button:has-text("Accept All")').click();
|
|
70
|
+
}
|
|
71
|
+
console.log('Accepting cookie popup');
|
|
72
|
+
await this.page.evaluate(() => {
|
|
73
|
+
const el = document.getElementById('transcend-consent-manager');
|
|
74
|
+
if (el) {
|
|
75
|
+
el.remove();
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Performs a robust, manual drag-and-drop by simulating mouse actions.
|
|
81
|
+
* This is useful for complex UIs where `dragTo` might fail.
|
|
82
|
+
* @param source The locator of the element to drag.
|
|
83
|
+
* @param target The locator of the drop target.
|
|
84
|
+
*/
|
|
85
|
+
async dragAndDrop(source, target) {
|
|
86
|
+
console.log(`Performing manual drag-and-drop from ${source} to ${target}`);
|
|
87
|
+
const sourceBounds = await source.boundingBox();
|
|
88
|
+
const targetBounds = await target.boundingBox();
|
|
89
|
+
if (sourceBounds && targetBounds) {
|
|
90
|
+
console.log(`Source bounds: ${JSON.stringify(sourceBounds)}`);
|
|
91
|
+
console.log(`Target bounds: ${JSON.stringify(targetBounds)}`);
|
|
92
|
+
await this.page.mouse.move(sourceBounds.x + sourceBounds.width / 2, sourceBounds.y + sourceBounds.height / 2);
|
|
93
|
+
await this.page.mouse.down();
|
|
94
|
+
await target.hover({ force: true });
|
|
95
|
+
await this.page.mouse.move(targetBounds.x + targetBounds.width / 2, targetBounds.y + targetBounds.height / 2, { steps: 5 });
|
|
96
|
+
await this.page.mouse.up();
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
throw new Error('Could not get bounding boxes for one or both drag-and-drop elements.');
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Waits for a given element to be hidden on the page.
|
|
104
|
+
* @param element - The Playwright Locator of the element to wait for.
|
|
105
|
+
* @param timeout - Optional timeout in milliseconds (default: 10000).
|
|
106
|
+
*/
|
|
107
|
+
async waitForElementToBeHidden(element, timeout = 10000) {
|
|
108
|
+
try {
|
|
109
|
+
console.log(`🔍 Waiting for element to be hidden: ${element.toString()} (timeout: ${timeout}ms)`);
|
|
110
|
+
await element.waitFor({ state: 'hidden', timeout });
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
console.error(`❌ Element did not become hidden: ${element.toString()} within ${timeout}ms`);
|
|
114
|
+
throw error;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
exports.CommonPageActions = CommonPageActions;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Page } from '@playwright/test';
|
|
2
|
+
export declare class CommonPageValidations {
|
|
3
|
+
protected page: Page;
|
|
4
|
+
constructor(page: Page);
|
|
5
|
+
/**
|
|
6
|
+
* Validates that the page is in fullscreen mode.
|
|
7
|
+
* @param isFullScreen A boolean indicating whether the page should be in fullscreen mode.
|
|
8
|
+
*/
|
|
9
|
+
validateFullScreen(isFullScreen: boolean): Promise<void>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CommonPageValidations = void 0;
|
|
4
|
+
const test_1 = require("@playwright/test");
|
|
5
|
+
class CommonPageValidations {
|
|
6
|
+
page;
|
|
7
|
+
constructor(page) {
|
|
8
|
+
this.page = page;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Validates that the page is in fullscreen mode.
|
|
12
|
+
* @param isFullScreen A boolean indicating whether the page should be in fullscreen mode.
|
|
13
|
+
*/
|
|
14
|
+
async validateFullScreen(isFullScreen) {
|
|
15
|
+
const fullscreenState = await this.page.evaluate(() => {
|
|
16
|
+
return !!document.fullscreenElement;
|
|
17
|
+
});
|
|
18
|
+
(0, test_1.expect)(fullscreenState).toBe(isFullScreen);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.CommonPageValidations = CommonPageValidations;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Locator, Page } from '@playwright/test';
|
|
2
|
+
export declare class CommonPageWaits {
|
|
3
|
+
protected page: Page;
|
|
4
|
+
constructor(page: Page);
|
|
5
|
+
/**
|
|
6
|
+
* Waits for an element's attribute to match a specific value or pattern.
|
|
7
|
+
* @param locator The Playwright Locator of the element.
|
|
8
|
+
* @param attribute The name of the attribute to check.
|
|
9
|
+
* @param value The expected value of the attribute (string or RegExp).
|
|
10
|
+
* @param timeout Optional timeout in milliseconds.
|
|
11
|
+
*/
|
|
12
|
+
waitForAttributeToBePresent(locator: Locator, attribute: string, value: string | RegExp, invert?: boolean, timeout?: number): Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* Waits for the page URL to match a specific value or pattern.
|
|
15
|
+
* - If 'url' is a string, it waits for an exact URL match.
|
|
16
|
+
* - If 'url' is a RegExp, it waits for the URL to match the pattern.
|
|
17
|
+
* (e.g., to check if URL contains 'login', use /login/).
|
|
18
|
+
* @param url The expected URL (string for exact match, or RegExp for pattern match).
|
|
19
|
+
* @param timeout Optional timeout in milliseconds.
|
|
20
|
+
*/
|
|
21
|
+
waitForURL(url: string | RegExp, timeout?: number): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Waits for an element to be hidden.
|
|
24
|
+
* @param locator The Playwright Locator of the element.
|
|
25
|
+
* @param timeout Optional timeout in milliseconds.
|
|
26
|
+
*/
|
|
27
|
+
waitForElementToBeHidden(locator: Locator, timeout?: number): Promise<void>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CommonPageWaits = void 0;
|
|
4
|
+
const test_1 = require("@playwright/test");
|
|
5
|
+
class CommonPageWaits {
|
|
6
|
+
page;
|
|
7
|
+
constructor(page) {
|
|
8
|
+
this.page = page;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Waits for an element's attribute to match a specific value or pattern.
|
|
12
|
+
* @param locator The Playwright Locator of the element.
|
|
13
|
+
* @param attribute The name of the attribute to check.
|
|
14
|
+
* @param value The expected value of the attribute (string or RegExp).
|
|
15
|
+
* @param timeout Optional timeout in milliseconds.
|
|
16
|
+
*/
|
|
17
|
+
async waitForAttributeToBePresent(locator, attribute, value, invert = false, timeout = 10000) {
|
|
18
|
+
await test_1.expect
|
|
19
|
+
.poll(async () => {
|
|
20
|
+
const attributeValue = await locator.getAttribute(attribute);
|
|
21
|
+
if (invert) {
|
|
22
|
+
return value instanceof RegExp
|
|
23
|
+
? !value.test(attributeValue || '')
|
|
24
|
+
: attributeValue !== value;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
return value instanceof RegExp
|
|
28
|
+
? value.test(attributeValue || '')
|
|
29
|
+
: attributeValue === value;
|
|
30
|
+
}
|
|
31
|
+
}, {
|
|
32
|
+
message: `Timed out waiting for attribute "${attribute}" to ${invert ? 'not be' : 'be'} "${value}" on ${locator.toString()}`,
|
|
33
|
+
timeout: timeout,
|
|
34
|
+
})
|
|
35
|
+
.toBe(true);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Waits for the page URL to match a specific value or pattern.
|
|
39
|
+
* - If 'url' is a string, it waits for an exact URL match.
|
|
40
|
+
* - If 'url' is a RegExp, it waits for the URL to match the pattern.
|
|
41
|
+
* (e.g., to check if URL contains 'login', use /login/).
|
|
42
|
+
* @param url The expected URL (string for exact match, or RegExp for pattern match).
|
|
43
|
+
* @param timeout Optional timeout in milliseconds.
|
|
44
|
+
*/
|
|
45
|
+
async waitForURL(url, timeout = 30000) {
|
|
46
|
+
await (0, test_1.expect)(this.page).toHaveURL(url, { timeout });
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Waits for an element to be hidden.
|
|
50
|
+
* @param locator The Playwright Locator of the element.
|
|
51
|
+
* @param timeout Optional timeout in milliseconds.
|
|
52
|
+
*/
|
|
53
|
+
async waitForElementToBeHidden(locator, timeout = 10000) {
|
|
54
|
+
await (0, test_1.expect)(locator).toBeHidden({ timeout });
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.CommonPageWaits = CommonPageWaits;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare class Logger {
|
|
2
|
+
private testDescription;
|
|
3
|
+
constructor(testDescription: string);
|
|
4
|
+
private log;
|
|
5
|
+
info(message: string): void;
|
|
6
|
+
debug(message: string): void;
|
|
7
|
+
warn(message: string): void;
|
|
8
|
+
error(message: string): void;
|
|
9
|
+
errorAndThrow(message: string): never;
|
|
10
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Logger = void 0;
|
|
4
|
+
class Logger {
|
|
5
|
+
testDescription;
|
|
6
|
+
constructor(testDescription) {
|
|
7
|
+
this.testDescription = testDescription;
|
|
8
|
+
}
|
|
9
|
+
log(level, message) {
|
|
10
|
+
const logMessage = `[${this.testDescription}] ${level.toUpperCase()}: ${message}`;
|
|
11
|
+
switch (level) {
|
|
12
|
+
case 'info':
|
|
13
|
+
console.info(logMessage);
|
|
14
|
+
break;
|
|
15
|
+
case 'warn':
|
|
16
|
+
console.warn(logMessage);
|
|
17
|
+
break;
|
|
18
|
+
case 'error':
|
|
19
|
+
console.error(logMessage);
|
|
20
|
+
break;
|
|
21
|
+
default:
|
|
22
|
+
console.log(logMessage);
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
info(message) {
|
|
27
|
+
this.log('info', message);
|
|
28
|
+
}
|
|
29
|
+
debug(message) {
|
|
30
|
+
this.log('debug', message);
|
|
31
|
+
}
|
|
32
|
+
warn(message) {
|
|
33
|
+
this.log('warn', message);
|
|
34
|
+
}
|
|
35
|
+
error(message) {
|
|
36
|
+
this.log('error', message);
|
|
37
|
+
}
|
|
38
|
+
errorAndThrow(message) {
|
|
39
|
+
throw new Error(`[${this.testDescription}] ${message}`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.Logger = Logger;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { BasePageActions } from './baseui/basepageactions';
|
|
2
|
+
import { BasePageValidations } from './baseui/basepagevalidations';
|
|
3
|
+
import { BasePageWaits } from './baseui/basepagewaits';
|
|
4
|
+
import { BaseApi } from './baseapi/baseapihelpers';
|
|
5
|
+
import { CommonPageActions } from './baseui/commonpageactions';
|
|
6
|
+
import { Logger } from './baseui/logger';
|
|
7
|
+
import path = require('path');
|
|
8
|
+
import fs = require('fs');
|
|
9
|
+
type MyFixtures = {
|
|
10
|
+
logger: Logger;
|
|
11
|
+
actions: BasePageActions;
|
|
12
|
+
validations: BasePageValidations;
|
|
13
|
+
waits: BasePageWaits;
|
|
14
|
+
baseApi: BaseApi;
|
|
15
|
+
commonPageActions: CommonPageActions;
|
|
16
|
+
};
|
|
17
|
+
export declare const test: import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions & MyFixtures, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions>;
|
|
18
|
+
export declare const expect: import("@playwright/test").Expect<{}>;
|
|
19
|
+
export { tags } from './constants/test-tags';
|
|
20
|
+
export { path, fs };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fs = exports.path = exports.tags = exports.expect = exports.test = void 0;
|
|
4
|
+
const test_1 = require("@playwright/test");
|
|
5
|
+
const basepageactions_1 = require("./baseui/basepageactions");
|
|
6
|
+
const basepagevalidations_1 = require("./baseui/basepagevalidations");
|
|
7
|
+
const basepagewaits_1 = require("./baseui/basepagewaits");
|
|
8
|
+
const baseapihelpers_1 = require("./baseapi/baseapihelpers");
|
|
9
|
+
const commonpageactions_1 = require("./baseui/commonpageactions");
|
|
10
|
+
const logger_1 = require("./baseui/logger");
|
|
11
|
+
const path = require("path");
|
|
12
|
+
exports.path = path;
|
|
13
|
+
const fs = require("fs");
|
|
14
|
+
exports.fs = fs;
|
|
15
|
+
exports.test = test_1.test.extend({
|
|
16
|
+
logger: async ({}, use, testInfo) => {
|
|
17
|
+
const logger = new logger_1.Logger(testInfo.title);
|
|
18
|
+
await use(logger);
|
|
19
|
+
},
|
|
20
|
+
/**
|
|
21
|
+
* Fixture for BasePageActions.
|
|
22
|
+
*/
|
|
23
|
+
actions: async ({ page, logger }, use) => {
|
|
24
|
+
const actions = new basepageactions_1.BasePageActions(page, logger);
|
|
25
|
+
await use(actions);
|
|
26
|
+
},
|
|
27
|
+
/**
|
|
28
|
+
* Fixture for BasePageValidations.
|
|
29
|
+
*/
|
|
30
|
+
validations: async ({ page, logger }, use) => {
|
|
31
|
+
const basePageValidations = new basepagevalidations_1.BasePageValidations(page, logger);
|
|
32
|
+
await use(basePageValidations);
|
|
33
|
+
},
|
|
34
|
+
/**
|
|
35
|
+
* Fixture for BasePageWaits.
|
|
36
|
+
*/
|
|
37
|
+
waits: async ({ page, logger }, use) => {
|
|
38
|
+
const waits = new basepagewaits_1.BasePageWaits(page, logger);
|
|
39
|
+
await use(waits);
|
|
40
|
+
},
|
|
41
|
+
/**
|
|
42
|
+
* Fixture for the BaseApi.
|
|
43
|
+
*/
|
|
44
|
+
baseApi: async ({ logger }, use) => {
|
|
45
|
+
const baseApi = new baseapihelpers_1.BaseApi(logger);
|
|
46
|
+
await use(baseApi);
|
|
47
|
+
},
|
|
48
|
+
/**
|
|
49
|
+
* Fixture for CommonPageActions.
|
|
50
|
+
*/
|
|
51
|
+
commonPageActions: async ({ page, logger }, use) => {
|
|
52
|
+
const commonPageActions = new commonpageactions_1.CommonPageActions(page, logger);
|
|
53
|
+
await use(commonPageActions);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
exports.expect = exports.test.expect;
|
|
57
|
+
var test_tags_1 = require("./constants/test-tags");
|
|
58
|
+
Object.defineProperty(exports, "tags", { enumerable: true, get: function () { return test_tags_1.tags; } });
|