@@ -66,25 +66,9 @@ function createLocatorHelper(page) {
6666 console.warn(`Error while finding element with ${type} locator: ${value}. Error: ${error.message}`);
6767 return null;
6868 }
69- },
69+ }
70+
7071
71- /**
72- * Finds all elements using the specified locator strategy
73- * @param {string} type - Locator type
74- * @param {string} value - Locator value
75- * @param {Object} [options] - Optional locator options
76- * @returns {Promise<import('@playwright/test').Locator>} Playwright locator for all matching elements
77- */
78- async findAllElements(type, value, options = {}) {
79- try {
80- const result = await this.findElement(type, value, options);
81- if (!result) return [];
82- return result.locator.all();
83- } catch (error) {
84- console.warn(`Failed to find all elements with ${type} locator: ${value}. Error: ${error.message}`);
85- return [];
86- }
87- },
8872
8973 /**
9074 * Waits for an element to be visible using the specified locator strategy
@@ -104,49 +88,8 @@ function createLocatorHelper(page) {
10488 } catch (error) {
10589 throw new Error(`Failed to wait for element with ${type} locator: ${value}. Error: ${error.message}`);
10690 }
107- },
108-
109- /**
110- * Stores a locator with a key for later use
111- * @param {string} key - Unique key to identify the locator
112- * @param {string} type - Locator type
113- * @param {string} value - Locator value
114- * @param {Object} [options] - Optional locator options
115- * @returns {Promise<void>}
116- */
117- async storeLocator(key, type, value, options = {}) {
118- try {
119- const result = await this.findElement(type, value, options);
120- if (!result) {
121- throw new Error(`Cannot store null locator with key ${key}`);
122- }
123- locatorStorage.set(key, { type, value, options, locator: result.locator });
124- } catch (error) {
125- throw new Error(`Failed to store locator with key ${key}. Error: ${error.message}`);
126- }
127- },
128-
129- /**
130- * Retrieves a stored locator by key
131- * @param {string} key - Key used to store the locator
132- * @returns {Promise<import('@playwright/test').Locator>} Stored Playwright locator
133- */
134- async getStoredLocator(key) {
135- const stored = locatorStorage.get(key);
136- if (!stored) {
137- throw new Error(`No locator found with key: ${key}`);
138- }
139- // Recreate locator to ensure it's fresh
140- const result = await this.findElement(stored.type, stored.value, stored.options);
141- return result ? result.locator : null;
142- },
143-
144- /**
145- * Clears all stored locators
146- */
147- clearStoredLocators() {
148- locatorStorage.clear();
14991 }
92+
15093 };
15194}
15295
0 commit comments