pw-element-interactions 0.0.7 → 0.0.8

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.
@@ -83,4 +83,13 @@ export declare class Interactions {
83
83
  * @returns A promise that resolves to the matched Playwright Locator, or null if not found.
84
84
  */
85
85
  getByText(baseLocator: Locator, pageName: string, elementName: string, desiredText: string, strict?: boolean): Promise<ReturnType<Page['locator']> | null>;
86
+ /**
87
+ * Types into the target element character by character with a specified delay.
88
+ * Use this for OTP inputs, search-as-you-type fields, or when `fill()`
89
+ * doesn't trigger necessary keyboard events (like 'keyup' or 'keydown').
90
+ * @param locator - The Playwright Locator pointing to the input element.
91
+ * @param text - The string of text to type sequentially.
92
+ * @param delay - Time in milliseconds to wait between key presses. Defaults to 100ms.
93
+ */
94
+ typeSequentially(locator: Locator, text: string, delay?: number): Promise<void>;
86
95
  }
@@ -196,5 +196,21 @@ class Interactions {
196
196
  }
197
197
  return locator;
198
198
  }
199
+ /**
200
+ * Types into the target element character by character with a specified delay.
201
+ * Use this for OTP inputs, search-as-you-type fields, or when `fill()`
202
+ * doesn't trigger necessary keyboard events (like 'keyup' or 'keydown').
203
+ * @param locator - The Playwright Locator pointing to the input element.
204
+ * @param text - The string of text to type sequentially.
205
+ * @param delay - Time in milliseconds to wait between key presses. Defaults to 100ms.
206
+ */
207
+ async typeSequentially(locator, text, delay = 100) {
208
+ await this.utils.waitForState(locator, 'visible');
209
+ console.log(`[Action] -> Typing "${text}" sequentially with a ${delay}ms delay.`);
210
+ await locator.pressSequentially(text, {
211
+ delay,
212
+ timeout: this.ELEMENT_TIMEOUT
213
+ });
214
+ }
199
215
  }
200
216
  exports.Interactions = Interactions;
@@ -183,4 +183,13 @@ export declare class Steps {
183
183
  * @param state - The state to wait for: 'visible' | 'attached' | 'hidden' | 'detached'. Defaults to 'visible'.
184
184
  */
185
185
  waitForState(pageName: string, elementName: string, state?: 'visible' | 'attached' | 'hidden' | 'detached'): Promise<void>;
186
+ /**
187
+ * Types text into a specific element character by character with a delay.
188
+ * Ideal for OTP inputs, search bars, or fields with sensitive 'keyup' listeners.
189
+ * @param pageName - The page or component grouping name in your repository.
190
+ * @param elementName - The specific element name in your repository.
191
+ * @param text - The string to type sequentially.
192
+ * @param delay - Optional delay between key presses in milliseconds (defaults to 100).
193
+ */
194
+ typeSequentially(pageName: string, elementName: string, text: string, delay?: number): Promise<void>;
186
195
  }
@@ -298,5 +298,18 @@ class Steps {
298
298
  const locator = await this.repo.get(this.page, pageName, elementName);
299
299
  await this.utils.waitForState(locator, state);
300
300
  }
301
+ /**
302
+ * Types text into a specific element character by character with a delay.
303
+ * Ideal for OTP inputs, search bars, or fields with sensitive 'keyup' listeners.
304
+ * @param pageName - The page or component grouping name in your repository.
305
+ * @param elementName - The specific element name in your repository.
306
+ * @param text - The string to type sequentially.
307
+ * @param delay - Optional delay between key presses in milliseconds (defaults to 100).
308
+ */
309
+ async typeSequentially(pageName, elementName, text, delay = 100) {
310
+ console.log(`[Step] -> Typing "${text}" sequentially into '${elementName}' in '${pageName}' (Delay: ${delay}ms)`);
311
+ const locator = await this.repo.get(this.page, pageName, elementName);
312
+ await this.interact.typeSequentially(locator, text, delay);
313
+ }
301
314
  }
302
315
  exports.Steps = Steps;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pw-element-interactions",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "description": "A robust, readable interaction and assertion Facade for Playwright. Abstract away boilerplate into semantic, English-like methods, making your test automation framework cleaner, easier to maintain, and accessible to non-developers.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",