@redhat-developer/page-objects 1.17.0 → 1.18.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.
Files changed (36) hide show
  1. package/out/components/AbstractElement.d.ts +77 -1
  2. package/out/components/AbstractElement.js +169 -12
  3. package/out/components/ActionButtonElementDropdown.js +14 -2
  4. package/out/components/activityBar/ViewControl.js +5 -1
  5. package/out/components/bottomBar/Views.js +25 -12
  6. package/out/components/editor/ContentAssist.js +2 -1
  7. package/out/components/editor/EditorView.js +50 -9
  8. package/out/components/editor/ExtensionEditorDetailsSection.js +31 -7
  9. package/out/components/editor/SettingsEditor.js +110 -28
  10. package/out/components/editor/TextEditor.js +120 -25
  11. package/out/components/menu/ContextMenu.js +27 -6
  12. package/out/components/menu/MenuItem.js +14 -1
  13. package/out/components/menu/TitleBar.js +15 -3
  14. package/out/components/sidebar/ViewSection.js +14 -4
  15. package/out/components/sidebar/WelcomeContent.js +10 -2
  16. package/out/components/sidebar/debug/DebugView.js +10 -2
  17. package/out/components/sidebar/extensions/ExtensionsViewSection.js +20 -5
  18. package/out/components/sidebar/scm/NewScmView.js +53 -13
  19. package/out/components/sidebar/scm/ScmView.js +12 -4
  20. package/out/components/sidebar/tree/TreeSection.js +11 -3
  21. package/out/components/sidebar/tree/custom/CustomTreeSection.js +22 -6
  22. package/out/components/sidebar/tree/debug/WatchSection.js +5 -1
  23. package/out/components/sidebar/tree/default/DefaultTreeSection.js +9 -1
  24. package/out/components/workbench/Notification.js +10 -2
  25. package/out/components/workbench/NotificationsCenter.js +11 -3
  26. package/out/components/workbench/Workbench.js +14 -4
  27. package/out/components/workbench/input/Input.js +45 -16
  28. package/out/components/workbench/input/InputBox.js +20 -4
  29. package/out/components/workbench/input/QuickOpenBox.js +11 -3
  30. package/out/errors/ExTesterError.d.ts +112 -0
  31. package/out/errors/ExTesterError.js +201 -0
  32. package/out/index.d.ts +2 -0
  33. package/out/index.js +2 -0
  34. package/out/utils/WaitHelper.d.ts +202 -0
  35. package/out/utils/WaitHelper.js +465 -0
  36. package/package.json +4 -4
@@ -0,0 +1,201 @@
1
+ "use strict";
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License", destination); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * https://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.VersionNotSupportedError = exports.PlatformNotSupportedError = exports.LocatorError = exports.TimeoutError = exports.ElementRecoveryError = exports.StaleElementError = exports.ElementNotInteractableError = exports.ElementNotVisibleError = exports.ElementNotFoundError = exports.ExTesterError = void 0;
20
+ exports.wrapError = wrapError;
21
+ /**
22
+ * Base error class for all ExTester-specific errors.
23
+ * Provides rich context for debugging test failures.
24
+ */
25
+ class ExTesterError extends Error {
26
+ context;
27
+ timestamp;
28
+ constructor(message, context = {}) {
29
+ super(message);
30
+ this.name = 'ExTesterError';
31
+ this.context = context;
32
+ this.timestamp = new Date();
33
+ // Maintain proper stack trace in V8 environments
34
+ if (Error.captureStackTrace) {
35
+ Error.captureStackTrace(this, this.constructor);
36
+ }
37
+ }
38
+ /**
39
+ * Get a detailed string representation of the error for logging.
40
+ */
41
+ toDetailedString() {
42
+ const lines = [`${this.name}: ${this.message}`, ` Timestamp: ${this.timestamp.toISOString()}`];
43
+ if (this.context.component) {
44
+ lines.push(` Component: ${this.context.component}`);
45
+ }
46
+ if (this.context.action) {
47
+ lines.push(` Action: ${this.context.action}`);
48
+ }
49
+ if (this.context.vscodeVersion) {
50
+ lines.push(` VS Code Version: ${this.context.vscodeVersion}`);
51
+ }
52
+ if (this.context.locator) {
53
+ lines.push(` Locator: ${this.context.locator}`);
54
+ }
55
+ if (this.context.details) {
56
+ lines.push(` Details: ${this.context.details}`);
57
+ }
58
+ if (this.context.cause) {
59
+ lines.push(` Caused by: ${this.context.cause.name}: ${this.context.cause.message}`);
60
+ }
61
+ return lines.join('\n');
62
+ }
63
+ toString() {
64
+ return this.toDetailedString();
65
+ }
66
+ }
67
+ exports.ExTesterError = ExTesterError;
68
+ /**
69
+ * Error thrown when an element cannot be found in the DOM.
70
+ */
71
+ class ElementNotFoundError extends ExTesterError {
72
+ constructor(message, context = {}) {
73
+ super(message, context);
74
+ this.name = 'ElementNotFoundError';
75
+ }
76
+ }
77
+ exports.ElementNotFoundError = ElementNotFoundError;
78
+ /**
79
+ * Error thrown when an element exists but is not visible.
80
+ */
81
+ class ElementNotVisibleError extends ExTesterError {
82
+ constructor(message, context = {}) {
83
+ super(message, context);
84
+ this.name = 'ElementNotVisibleError';
85
+ }
86
+ }
87
+ exports.ElementNotVisibleError = ElementNotVisibleError;
88
+ /**
89
+ * Error thrown when an element cannot be interacted with (e.g., blocked, disabled).
90
+ */
91
+ class ElementNotInteractableError extends ExTesterError {
92
+ constructor(message, context = {}) {
93
+ super(message, context);
94
+ this.name = 'ElementNotInteractableError';
95
+ }
96
+ }
97
+ exports.ElementNotInteractableError = ElementNotInteractableError;
98
+ /**
99
+ * Error thrown when an element reference has become stale (DOM was modified).
100
+ */
101
+ class StaleElementError extends ExTesterError {
102
+ constructor(message, context = {}) {
103
+ super(message, context);
104
+ this.name = 'StaleElementError';
105
+ }
106
+ }
107
+ exports.StaleElementError = StaleElementError;
108
+ /**
109
+ * Error thrown when element recovery/reinitialization fails.
110
+ */
111
+ class ElementRecoveryError extends ExTesterError {
112
+ constructor(message, context = {}) {
113
+ super(message, context);
114
+ this.name = 'ElementRecoveryError';
115
+ }
116
+ }
117
+ exports.ElementRecoveryError = ElementRecoveryError;
118
+ /**
119
+ * Error thrown when a timeout occurs waiting for a condition.
120
+ */
121
+ class TimeoutError extends ExTesterError {
122
+ timeoutMs;
123
+ constructor(message, timeoutMs, context = {}) {
124
+ super(message, context);
125
+ this.name = 'TimeoutError';
126
+ this.timeoutMs = timeoutMs;
127
+ }
128
+ toDetailedString() {
129
+ const base = super.toDetailedString();
130
+ return `${base}\n Timeout: ${this.timeoutMs}ms`;
131
+ }
132
+ }
133
+ exports.TimeoutError = TimeoutError;
134
+ /**
135
+ * Error thrown when a locator fails to match any elements.
136
+ */
137
+ class LocatorError extends ExTesterError {
138
+ constructor(message, context = {}) {
139
+ super(message, context);
140
+ this.name = 'LocatorError';
141
+ }
142
+ }
143
+ exports.LocatorError = LocatorError;
144
+ /**
145
+ * Error thrown for platform-specific limitations (e.g., macOS native dialogs).
146
+ */
147
+ class PlatformNotSupportedError extends ExTesterError {
148
+ platform;
149
+ constructor(message, platform = process.platform, context = {}) {
150
+ super(message, context);
151
+ this.name = 'PlatformNotSupportedError';
152
+ this.platform = platform;
153
+ }
154
+ toDetailedString() {
155
+ const base = super.toDetailedString();
156
+ return `${base}\n Platform: ${this.platform}`;
157
+ }
158
+ }
159
+ exports.PlatformNotSupportedError = PlatformNotSupportedError;
160
+ /**
161
+ * Error thrown when an operation is not supported for the current VS Code version.
162
+ */
163
+ class VersionNotSupportedError extends ExTesterError {
164
+ requiredVersion;
165
+ currentVersion;
166
+ constructor(message, requiredVersion, currentVersion, context = {}) {
167
+ super(message, { ...context, vscodeVersion: currentVersion });
168
+ this.name = 'VersionNotSupportedError';
169
+ this.requiredVersion = requiredVersion;
170
+ this.currentVersion = currentVersion;
171
+ }
172
+ toDetailedString() {
173
+ const base = super.toDetailedString();
174
+ return `${base}\n Required Version: ${this.requiredVersion}`;
175
+ }
176
+ }
177
+ exports.VersionNotSupportedError = VersionNotSupportedError;
178
+ /**
179
+ * Utility to wrap native Selenium errors with ExTester context.
180
+ */
181
+ function wrapError(originalError, context) {
182
+ const message = originalError.message;
183
+ if (originalError.name === 'StaleElementReferenceError') {
184
+ return new StaleElementError(message, { ...context, cause: originalError });
185
+ }
186
+ if (originalError.name === 'NoSuchElementError') {
187
+ return new ElementNotFoundError(message, { ...context, cause: originalError });
188
+ }
189
+ if (originalError.name === 'ElementNotInteractableError' || originalError.name === 'ElementClickInterceptedError') {
190
+ return new ElementNotInteractableError(message, { ...context, cause: originalError });
191
+ }
192
+ if (originalError.name === 'ElementNotVisibleError') {
193
+ return new ElementNotVisibleError(message, { ...context, cause: originalError });
194
+ }
195
+ if (originalError.name === 'TimeoutError') {
196
+ return new TimeoutError(message, 0, { ...context, cause: originalError });
197
+ }
198
+ // Generic fallback
199
+ return new ExTesterError(message, { ...context, cause: originalError });
200
+ }
201
+ //# sourceMappingURL=ExTesterError.js.map
package/out/index.d.ts CHANGED
@@ -18,6 +18,8 @@ import { WebDriver } from 'selenium-webdriver';
18
18
  export * from 'selenium-webdriver';
19
19
  export * from './locators/locators';
20
20
  export * from './errors/NullAttributeError';
21
+ export * from './errors/ExTesterError';
22
+ export * from './utils/WaitHelper';
21
23
  export * from './components/menu/Menu';
22
24
  export * from './components/menu/MenuItem';
23
25
  export * from './components/menu/TitleBar';
package/out/index.js CHANGED
@@ -37,6 +37,8 @@ const loader_1 = require("./locators/loader");
37
37
  __exportStar(require("selenium-webdriver"), exports);
38
38
  __exportStar(require("./locators/locators"), exports);
39
39
  __exportStar(require("./errors/NullAttributeError"), exports);
40
+ __exportStar(require("./errors/ExTesterError"), exports);
41
+ __exportStar(require("./utils/WaitHelper"), exports);
40
42
  __exportStar(require("./components/menu/Menu"), exports);
41
43
  __exportStar(require("./components/menu/MenuItem"), exports);
42
44
  __exportStar(require("./components/menu/TitleBar"), exports);
@@ -0,0 +1,202 @@
1
+ /**
2
+ * Licensed to the Apache Software Foundation (ASF) under one or more
3
+ * contributor license agreements. See the NOTICE file distributed with
4
+ * this work for additional information regarding copyright ownership.
5
+ * The ASF licenses this file to You under the Apache License, Version 2.0
6
+ * (the "License", destination); you may not use this file except in compliance with
7
+ * the License. You may obtain a copy of the License at
8
+ *
9
+ * https://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { WebDriver, WebElement, Locator } from 'selenium-webdriver';
18
+ export interface WaitOptions {
19
+ /** Maximum time to wait in milliseconds */
20
+ timeout?: number;
21
+ /** Interval between condition checks in milliseconds */
22
+ pollInterval?: number;
23
+ /** Custom error message when timeout is reached */
24
+ message?: string;
25
+ }
26
+ export interface RetryOptions {
27
+ /** Maximum number of retry attempts */
28
+ maxRetries?: number;
29
+ /** Delay between retries in milliseconds */
30
+ retryDelay?: number;
31
+ /** Multiplier for exponential backoff (default: 1 = linear) */
32
+ backoffMultiplier?: number;
33
+ /** Function to determine if error is retryable */
34
+ isRetryable?: (error: Error) => boolean;
35
+ }
36
+ export interface StabilityOptions extends WaitOptions {
37
+ /** Number of consecutive stable checks required */
38
+ stableChecks?: number;
39
+ /** Interval between stability checks in milliseconds */
40
+ stabilityInterval?: number;
41
+ }
42
+ /**
43
+ * Utility class for condition-based waiting operations.
44
+ * Replaces arbitrary sleep() calls with intelligent waiting strategies.
45
+ */
46
+ export declare class WaitHelper {
47
+ private readonly driver;
48
+ private readonly defaultTimeout;
49
+ private readonly defaultPollInterval;
50
+ constructor(driver: WebDriver, defaultTimeout?: number, defaultPollInterval?: number);
51
+ /**
52
+ * Wait for a condition to become truthy.
53
+ * @param condition Async function that returns a value - waiting stops when value is truthy
54
+ * @param options Wait configuration options
55
+ * @returns The truthy value returned by the condition
56
+ */
57
+ forCondition<T>(condition: () => Promise<T>, options?: WaitOptions): Promise<T>;
58
+ /**
59
+ * Wait for an element's attribute to have a specific value.
60
+ * @param element The WebElement to check
61
+ * @param attribute Name of the attribute
62
+ * @param value Expected value
63
+ * @param options Wait configuration options
64
+ */
65
+ forAttributeValue(element: WebElement, attribute: string, value: string, options?: WaitOptions): Promise<void>;
66
+ /**
67
+ * Wait for an element's attribute to contain a specific value.
68
+ * @param element The WebElement to check
69
+ * @param attribute Name of the attribute
70
+ * @param value Value to search for
71
+ * @param options Wait configuration options
72
+ */
73
+ forAttributeContains(element: WebElement, attribute: string, value: string, options?: WaitOptions): Promise<void>;
74
+ /**
75
+ * Wait for an element to become stable (position/size stops changing).
76
+ * Useful for waiting after animations or dynamic content loading.
77
+ *
78
+ * Note: If the element becomes stale (removed from DOM), this method returns
79
+ * successfully since element removal is a form of "stability".
80
+ *
81
+ * @param element The WebElement to monitor
82
+ * @param options Stability configuration options
83
+ */
84
+ forStable(element: WebElement, options?: StabilityOptions): Promise<void>;
85
+ /**
86
+ * Wait for an element to become visible.
87
+ * @param element The WebElement to check
88
+ * @param options Wait configuration options
89
+ */
90
+ forVisible(element: WebElement, options?: WaitOptions): Promise<void>;
91
+ /**
92
+ * Wait for an element to become invisible.
93
+ * @param element The WebElement to check
94
+ * @param options Wait configuration options
95
+ */
96
+ forNotVisible(element: WebElement, options?: WaitOptions): Promise<void>;
97
+ /**
98
+ * Wait for an element to become enabled.
99
+ * @param element The WebElement to check
100
+ * @param options Wait configuration options
101
+ */
102
+ forEnabled(element: WebElement, options?: WaitOptions): Promise<void>;
103
+ /**
104
+ * Wait for the number of elements matching a condition to stabilize.
105
+ * Useful for lists that are loading items dynamically.
106
+ * @param getCount Function that returns the current count
107
+ * @param options Stability configuration options
108
+ */
109
+ forCountStable(getCount: () => Promise<number>, options?: StabilityOptions): Promise<number>;
110
+ /**
111
+ * Wait for text content to be present in an element.
112
+ * @param element The WebElement to check
113
+ * @param text Expected text (partial match)
114
+ * @param options Wait configuration options
115
+ */
116
+ forTextPresent(element: WebElement, text: string, options?: WaitOptions): Promise<void>;
117
+ /**
118
+ * Wait for an element's class list to contain a specific class.
119
+ * @param element The WebElement to check
120
+ * @param className Class name to look for
121
+ * @param options Wait configuration options
122
+ */
123
+ forClass(element: WebElement, className: string, options?: WaitOptions): Promise<void>;
124
+ /**
125
+ * Wait for an element's class list to NOT contain a specific class.
126
+ * @param element The WebElement to check
127
+ * @param className Class name that should not be present
128
+ * @param options Wait configuration options
129
+ */
130
+ forNoClass(element: WebElement, className: string, options?: WaitOptions): Promise<void>;
131
+ /**
132
+ * Wait for an element to be clickable (visible AND enabled).
133
+ * @param element The WebElement to check
134
+ * @param options Wait configuration options
135
+ */
136
+ forClickable(element: WebElement, options?: WaitOptions): Promise<void>;
137
+ /**
138
+ * Wait for text content to match exactly or a regex pattern.
139
+ * @param element The WebElement to check
140
+ * @param expected Expected text string or RegExp pattern
141
+ * @param options Wait configuration options
142
+ */
143
+ forTextContent(element: WebElement, expected: string | RegExp, options?: WaitOptions): Promise<void>;
144
+ /**
145
+ * Wait for a specific number of elements to be present.
146
+ * @param parent Parent element or driver to search within
147
+ * @param locator Locator for the elements
148
+ * @param expectedCount Expected number of elements
149
+ * @param options Wait configuration options
150
+ */
151
+ forElementCount(parent: WebElement | WebDriver, locator: Locator, expectedCount: number, options?: WaitOptions): Promise<WebElement[]>;
152
+ /**
153
+ * Wait for at least one element matching the locator to be present.
154
+ * @param parent Parent element or driver to search within
155
+ * @param locator Locator for the element
156
+ * @param options Wait configuration options
157
+ * @returns The first matching element
158
+ */
159
+ forElementLocated(parent: WebElement | WebDriver, locator: Locator, options?: WaitOptions): Promise<WebElement>;
160
+ /**
161
+ * Wait for no elements matching the locator to be present (element removed).
162
+ * @param parent Parent element or driver to search within
163
+ * @param locator Locator for the element
164
+ * @param options Wait configuration options
165
+ */
166
+ forNoElement(parent: WebElement | WebDriver, locator: Locator, options?: WaitOptions): Promise<void>;
167
+ /**
168
+ * Wait for element to be removed from DOM or become stale.
169
+ * @param element The WebElement to monitor
170
+ * @param options Wait configuration options
171
+ */
172
+ forElementRemoved(element: WebElement, options?: WaitOptions): Promise<void>;
173
+ /**
174
+ * Wait for any of the conditions to be met (OR logic).
175
+ * @param conditions Array of condition functions
176
+ * @param options Wait configuration options
177
+ * @returns Index of the first condition that was met
178
+ */
179
+ forAnyCondition(conditions: Array<() => Promise<boolean>>, options?: WaitOptions): Promise<number>;
180
+ /**
181
+ * Execute a function with automatic retry on failure.
182
+ * @param fn The function to execute
183
+ * @param options Retry configuration options
184
+ * @returns The result of the function
185
+ */
186
+ withRetry<T>(fn: () => Promise<T>, options?: RetryOptions): Promise<T>;
187
+ /**
188
+ * Simple sleep helper - use sparingly and prefer condition-based waits.
189
+ * @param ms Milliseconds to sleep
190
+ */
191
+ sleep(ms: number): Promise<void>;
192
+ /**
193
+ * Get the WebDriver instance.
194
+ */
195
+ getDriver(): WebDriver;
196
+ private rectsEqual;
197
+ }
198
+ /**
199
+ * Create a WaitHelper instance bound to a WebDriver.
200
+ * Convenience factory function for quick access.
201
+ */
202
+ export declare function createWaitHelper(driver: WebDriver, defaultTimeout?: number): WaitHelper;